Hi!!!
I need some help:
I have a program: myProgram.pyw, and I want it like myProgram.exe so anyone can run it in a windows xp without installing nothing.
I've read how py2exe works and I undersand it when is a simple program.
myProgram.pyw uses ImageGrab module and pyHook module.
How I can create myProgram.exe that "include" that modules and run with no problems¿??
Thanks!!!!
20 4556
Hi!!!
I need some help:
I have a program: myProgram.pyw, and I want it like myProgram.exe so anyone can run it in a windows xp without installing nothing.
I've read how py2exe works and I undersand it when is a simple program.
myProgram.pyw uses ImageGrab module and pyHook module.
How I can create myProgram.exe that "include" that modules and run with no problems¿??
Thanks!!!!
I've been working with Py2Exe and have learned some tricks. I have posted here (which is NOT for Q&A) and other placed also in the Articles Section.
Do some work on you setup file and post back IN THIS THREAD.
Thanks for joining.
I've been working with Py2Exe and have learned some tricks. I have posted here (which is NOT for Q&A) and other placed also in the Articles Section.
Do some work on you setup file and post back IN THIS THREAD.
Thanks for joining.
Hi! sorry for PM you, I didn't know about the rules.
Here I have my simple program: a screen shot taker: -
import ImageGrab,pythoncom,pyHook,os
-
from datetime import *
-
def OnKeyboardEvent(event):
-
if(event.Key=="F7"):
-
#catching the f7 event
-
s=getDateInString()
-
aux=r"C:\\ScreenShots\\ss"
-
path=aux+s+".jpg"
-
print path
-
img = ImageGrab.grab()
-
img.save(path)
-
return True
-
def getDateInString():
-
#tunning the path
-
s=str(datetime.today()).split(' ')
-
return s[0]+'-'+s[1].replace(':','-').split('.')[0]
-
# if dont exist, create directory where all ss will be saved
-
if(os.access("C:\\ScreenShots",os.F_OK)==False):
-
os.mkdir("C:\\ScreenShots")
-
# create a hook manager
-
hm = pyHook.HookManager()
-
# watch for all mouse events
-
hm.KeyDown = OnKeyboardEvent
-
# set the hook
-
hm.HookKeyboard()
-
# wait forever
-
pythoncom.PumpMessages()
-
it's named sstaker.pyw.
the ImageGrab module is Python Imaging Library 1.1.6 for Python 2.5 (Windows only) on http://www.pythonware.com/products/pil/index.htm
the pyHook module is http://sourceforge.net/project/downl...5.exe&37280531
for windows too.
os and datetime comes with python.
If only I could get a sstaker.exe which I can pass anyone with windows xp without that person installs nothing previously.
oh :( At least tell me if it is possible to do, because I'm trying to get it for more than one month asking in a lot of forums and reading tutorials...
oh :( At least tell me if it is possible to do, because I'm trying to get it for more than one month asking in a lot of forums and reading tutorials...
Sorry, Freddy. My connections been wonky all day. It is possible and probably even easy. Give me a little bit to get to this.
Thanks.
Sorry, Freddy. My connections been wonky all day. It is possible and probably even easy. Give me a little bit to get to this.
Thanks.
Re-subscribing and bumping...
Hi! sorry for PM you, I didn't know about the rules.
Here I have my simple program: a screen shot taker: -
import ImageGrab,pythoncom,pyHook,os
-
from datetime import *
-
def OnKeyboardEvent(event):
-
if(event.Key=="F7"):
-
#catching the f7 event
-
s=getDateInString()
-
aux=r"C:\\ScreenShots\\ss"
-
path=aux+s+".jpg"
-
print path
-
img = ImageGrab.grab()
-
img.save(path)
-
return True
-
def getDateInString():
-
#tunning the path
-
s=str(datetime.today()).split(' ')
-
return s[0]+'-'+s[1].replace(':','-').split('.')[0]
-
# if dont exist, create directory where all ss will be saved
-
if(os.access("C:\\ScreenShots",os.F_OK)==False):
-
os.mkdir("C:\\ScreenShots")
-
# create a hook manager
-
hm = pyHook.HookManager()
-
# watch for all mouse events
-
hm.KeyDown = OnKeyboardEvent
-
# set the hook
-
hm.HookKeyboard()
-
# wait forever
-
pythoncom.PumpMessages()
-
it's named sstaker.pyw.
the ImageGrab module is Python Imaging Library 1.1.6 for Python 2.5 (Windows only) on http://www.pythonware.com/products/pil/index.htm
the pyHook module is http://sourceforge.net/project/downl...5.exe&37280531
for windows too.
os and datetime comes with python.
If only I could get a sstaker.exe which I can pass anyone with windows xp without that person installs nothing previously.
Your post is very complete and allowed me to get you program up and running in no time. Your program is perhaps a little too simple (no way to kill it other than T.M.) Seems like it needs some work to make sure that it doesn't steal F7 from any other running programs, also. I'll run it through py2exe, though (but don't have a lot of time at the moment).
I am curious for the need for such a program when windows will capture the screen to the clipboard which give users a chance to select format and directory (features that would be a great addition to your program).
Your post is very complete and allowed me to get you program up and running in no time. Your program is perhaps a little too simple (no way to kill it other than T.M.) Seems like it needs some work to make sure that it doesn't steal F7 from any other running programs, also. I'll run it through py2exe, though (but don't have a lot of time at the moment).
I am curious for the need for such a program when windows will capture the screen to the clipboard which give users a chance to select format and directory (features that would be a great addition to your program).
Hi, you are right, my program is not very useful, but is the first program I do that interaction with the operating system, and I wanted that do a simple task like that.
The main utility of this little program is that saves the picture with the name year-month-day-hour-min-sec in jpg in a directory every time the user press F7. I know the user could do that with the Impr pant key but he would have to open Paint and paste and save it on jpg and put a name and select the directory (maybe there is another form, will be great if you could tell me about). And the idea is, that if I'm playing a game (not counter strike or so that have a lot of video recorders, a simple and not famous game) I can be playing and taking the screen shots just pressing F7 the times I want.
Anyway, will be great if you could help me improving my little program (I've been thinking in a system tray icon or so too) but will be great if I knew how to make an exe of my programs because most people wont install python and all the modules just for see how my little program works.
Thank you very much!
Hi, you are right, my program is not very useful, but is the first program I do that interaction with the operating system, and I wanted that do a simple task like that.
The main utility of this little program is that saves the picture with the name year-month-day-hour-min-sec in jpg in a directory every time the user press F7. I know the user could do that with the Impr pant key but he would have to open Paint and paste and save it on jpg and put a name and select the directory (maybe there is another form, will be great if you could tell me about). And the idea is, that if I'm playing a game (not counter strike or so that have a lot of video recorders, a simple and not famous game) I can be playing and taking the screen shots just pressing F7 the times I want.
Anyway, will be great if you could help me improving my little program (I've been thinking in a system tray icon or so too) but will be great if I knew how to make an exe of my programs because most people wont install python and all the modules just for see how my little program works.
Thank you very much!
Very well said, Freddy. I'll make some time this weekend for the py2exe part (I need the practice anyway). Then we can work on a more freindly "environment" for your utility to live in.
Very well said, Freddy. I'll make some time this weekend for the py2exe part (I need the practice anyway). Then we can work on a more freindly "environment" for your utility to live in.
Thanks! man you rock!!
Thanks! man you rock!!
Here's one thing that I did to make your program more managable:
Change the extention to .py so that the python stdout/stderr window comes up when you double-click the file (if you are still needing the command-line, we can adjust your system). That way, at least the program can be killed without using Task Manager.
Here's one thing that I did to make your program more managable:
Change the extention to .py so that the python stdout/stderr window comes up when you double-click the file (if you are still needing the command-line, we can adjust your system). That way, at least the program can be killed without using Task Manager.
Thanks, that was how I had it before changing the extension to .pyw. I like that a program runs without the console behind him. I was thinking and googleing for some icon in the system tray (down right on windows xp, where emule, messenger are) seems like PyQt can do it. Do you know something about?
Will be so well-looked an icon in the system try with the right-mouse button opcion "close" or something like that.
What do you think? Thanks!
Thanks, that was how I had it before changing the extension to .pyw. I like that a program runs without the console behind him. I was thinking and googleing for some icon in the system tray (down right on windows xp, where emule, messenger are) seems like PyQt can do it. Do you know something about?
Will be so well-looked an icon in the system try with the right-mouse button opcion "close" or something like that.
What do you think? Thanks!
My GUI toolkit is wxPython. It can do system tray icons, but I haven't tried it yet. I really like the idea, though.
Maybe if I make a package with the classes that are involved in my little program (I'm thinking like a .jar in java, I don't know how it works in python) would be easier get my "sstaker.exe"?
Maybe if I make a package with the classes that are involved in my little program (I'm thinking like a .jar in java, I don't know how it works in python) would be easier get my "sstaker.exe"?
Well, Freddy, the ball's in your court now. I've worked on this for as long as I can. Sorry for screwing up the names. This setup script (when run in the same directory as you program will compile your sstaker.exe (I called it ImageGrabber) on line 20. For some reason (maybe this won't work at all) the events are not being registered with pyHook. The pumpmessages() seems to be working since the program doesn't exit immediately. I think that if you track down the "missing modules" error by playing with "includes" and "excludes" lists, you may have success. Have fun! - # Py2Exe version 6.3 setup file for wxPython GUI programs.
-
# Creates a single exe file.
-
# It's easiest to add this wxPython2Exe.py file into the same
-
# folder with the source file and an optional iconfile like "icon.ico"
-
# (if you add your own icon file, remove the comment in front of icon_resources).
-
# Simply change the filename to whatever you called your source file.
-
# Optionally edit the version info and add the name of your icon file.
-
# Now run wxPython2Exe.py ...
-
# Two subfolders will be created called build and dist.
-
# The dist folder contains your .exe file, MSVCR71.dll and w9xpopen.exe
-
# Your .exe file contains your code, all neded modules and the Python interpreter.
-
# The MSVCR71.dll can be distributed, but is often already in the system32 folder.
-
-
from distutils.core import setup
-
import py2exe
-
import sys
-
-
-
# enter the filename of your wxPython code file to compile ...
-
filename = "ImageGrabber.py"
-
-
# ... this creates the filename of your .exe file in the dist folder
-
if filename.endswith(".py"):
-
distribution = filename[:-3]
-
elif filename.endswith(".pyw"):
-
distribution = filename[:-4]
-
-
-
# if run without args, build executables in quiet mode
-
if len(sys.argv) == 1:
-
sys.argv.append("py2exe")
-
sys.argv.append("-q")
-
-
class Target:
-
def __init__(self, **kw):
-
self.__dict__.update(kw)
-
# for the versioninfo resources, edit to your needs
-
self.version = "0.0.1"
-
self.company_name = "freddypyther"
-
self.copyright = "no copyright"
-
self.name = "Background Image Grabber"
-
-
################################################################
-
# The manifest will be inserted as resource into your .exe. This
-
# gives the controls the Windows XP appearance (if run on XP ;-)
-
#
-
# Another option would be to store it in a file named
-
# test_wx.exe.manifest, and copy it with the data_files option into
-
# the dist-dir.
-
#
-
manifest_template = '''
-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-
<assemblyIdentity
-
version="5.0.0.0"
-
processorArchitecture="x86"
-
name="%(prog)s"
-
type="win32"
-
/>
-
<description>%(prog)s Program</description>
-
<dependency>
-
<dependentAssembly>
-
<assemblyIdentity
-
type="win32"
-
name="Microsoft.Windows.Common-Controls"
-
version="6.0.0.0"
-
processorArchitecture="X86"
-
publicKeyToken="6595b64144ccf1df"
-
language="*"
-
/>
-
</dependentAssembly>
-
</dependency>
-
</assembly>
-
'''
-
-
RT_MANIFEST = 24
-
-
# description is the versioninfo resource
-
# script is the wxPython code file
-
# manifest_template is the above XML code
-
# distribution will be the exe filename
-
# icon_resource is optional, remove any comment and give it an iconfile you have
-
# otherwise a default icon is used
-
# dest_base will be the exe filename
-
test_grabber = Target(
-
description = "A non-GUI app",
-
script = filename,
-
other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog=distribution))],
-
#icon_resources = [(1, "icon.ico")],
-
dest_base = distribution)
-
-
################################################################
-
excludes = ["pywin.debugger", "pywin.debugger.dbgcon",
-
"pywin.dialogs", "pywin.dialogs.list",
-
"Tkconstants","Tkinter","tcl",
-
] # "pywin",
-
includes = ['PIL._imaging', 'pyHook.cpyHook']
-
-
setup(
-
# Need a console to be able to kill this non-GUI deamon #
-
## windows = [test_grabber,],
-
## console = [filename],
-
console = [test_grabber],
-
options = {"py2exe": {"compressed": 1,
-
"optimize": 2,
-
"ascii": 1,
-
"bundle_files": 1,
-
"packages":["PIL", "pyHook",],
-
"excludes":excludes,
-
"includes":includes}}, #
-
zipfile = None,
-
)
-
By the way, here's my ImageGrabber.py: - """ImageGrabber.py: Grabs a screenshot and save it to a file with a dated name."""
-
-
import ImageGrab, pythoncom, pyHook, os
-
from datetime import *
-
-
if(os.access("C:\\ScreenShots",os.F_OK)==False):
-
# if dont exist, create directory where all ss will be saved
-
os.mkdir("C:\\ScreenShots")
-
-
def getDateInString():
-
#tunning the path
-
s = str(datetime.today()).split(' ')
-
return s[0]+'-'+s[1].replace(':', '-').split('.')[0]
-
-
def OnKeyboardEvent(event):
-
print "Got a keyboard event"
-
if(event.Key == "F7"):
-
#catching the f7 event
-
s = getDateInString()
-
aux = r"D:\\ScreenShots\\ss"
-
path = aux + s + ".jpg"
-
print path
-
img = ImageGrab.grab()
-
img.save(path)
-
return True
-
-
print "Setting up the Grabber"
-
# create a hook manager
-
hm = pyHook.HookManager()
-
# watch for all KeyDown events
-
print hm
-
hm.SubscribeKeyDown(OnKeyboardEvent)
-
# set the hook
-
hm.HookKeyboard()
-
# wait forever
-
pythoncom.PumpMessages()
-
OH!! thank you very much man!!! let's see if I could end this project up.
Well, I've had some errors trying to run successfully the setup.py, some windows DLL and some quite difficult stuff for me. I'm so grateful for your help. I'm wondering that if the problem is with the module PyHook, maybe Tkinter can catch keyevents the same way it does pyhook? It could be worth that I try to do it with tkinter instead of pyHook, then I'll just have to take care about the ImageGrab module if there is some error with modules.
Thanks for all your help!
Well, I've had some errors trying to run successfully the setup.py, some windows DLL and some quite difficult stuff for me. I'm so grateful for your help. I'm wondering that if the problem is with the module PyHook, maybe Tkinter can catch keyevents the same way it does pyhook? It could be worth that I try to do it with tkinter instead of pyHook, then I'll just have to take care about the ImageGrab module if there is some error with modules.
Thanks for all your help!
There is a screen grabber example in Tkinter, somewhere. I'll have a look around and see if I can find that for you. I used to use it back before I knew about the PtrScn button on my keyboard.
There is a screen grabber example in Tkinter, somewhere. I'll have a look around and see if I can find that for you. I used to use it back before I knew about the PtrScn button on my keyboard.
Nope, not Tkinter. It's win32. On my system the path is "D:\Python24\Lib\site-packages\win32\Demos" and the file is called "print_desktop.py". Good luck.
Well I've been trying for long time with no succeed :( . So the only thing I can do now is ask if someone know how to get the "sstaker.exe" if he/she could create it and send it to me via email or something (I know it's a dangerous stuff but I don't know how to create that exe, hundreds of windows dll errors with no solucion).
Thanks again to all !
Sign in to post your reply or Sign up for a free account.
Similar topics
by: QQ June |
last post by:
Hello,
I have some java classes. But, I don't want my users to type "java
my_java_program" every time they run the java class ?
How do I pack them together into one executable file, like...
|
by: Martin Bless |
last post by:
I need to access a MSSQL database (MS-Sql, not MySQL!)and would very
much like to use mssql-0.09.tar.gz which is available from
http://www.object-craft.com.au/projects/mssql/download.html
...
|
by: Seelan Rajagopal |
last post by:
Hey Guys!
Im Compiling a simple program is the command promt. I have set all the
paths needed to run the compiler. But when I use csc myprogram.cs, it says
that the program does not have an entry...
|
by: Aaron Queenan |
last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the
following error message:
Linking...
LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport
LINK : error...
|
by: Rudy Ray Moore |
last post by:
Hi guys,
I just upgraded to "Visual Studio .net 2003 7.1 c++" from VS6.
Some things I like (proper for loop variable scoping, for example), but some
other things are troubling me.
One...
|
by: Christina N |
last post by:
When compiling my ASP.Net application, VS puts the new DLL under the local
cached directory 'VSWebCache' in stead of on the server. How can I make it
save the DLL file on the server when compiling?...
|
by: Simon Faulkner |
last post by:
Pardon me if this has been done to death but I can't find a simple
explanation.
I love Python for it's ease and speed of development especially for the
"Programming Challenged" like me but why...
|
by: NvrBst |
last post by:
I'm wondering if this is possible... Basically say I have a lot of .cs
files but only 1 of them changes. Is there a way (with the csc.exe, or
VS.NET 2005, or another C# Compiler), that I can...
|
by: =?Utf-8?B?amVmZmVyeQ==?= |
last post by:
i need help compiling code dynamically it may involve some reflection so if
any one is any good in that field or compiling code this would be a great
time to show me what you know. by the way my...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |