Re: [Tutor] Print Screen

2006-11-04 Thread Chris Hengge
Wow, that hasn't come up in my searching, thanks! Looks like you are right and the project is dead, but the author did toss there code up for viewing so I can stumble around a bit there. 
On 11/3/06, Jonathon Sisson [EMAIL PROTECTED] wrote:
Chris,I don't know if this has been mentioned yet, but this site might be useful:http://bdash.net.nz/blog/2003/12/24/python-vnc-client/
The code base has (last I heard) fallen stagnant, but it may very wellbe worth a look as a starting point for your VNC project idea.JonathonChris Hengge wrote: Wow.. I have visions of writing a little wanna-be VNC client/server now
 using the ImageGrab.grab() =D This ImageGrab trick does exactly what I wanted. Thanks for the tip! Actually, I want to write a little package for the learning experience sometime over the holidays (plus I use VNC fairly often), but I can't
 find any direction, or any already made packages for python for the VNC protocol (no libs?). On 11/2/06, *Luke Paireepinart* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote: Anyone know of a way to capture special keys like Print Screen?
 I have a small script to grab all they keycodes, but it doesn't seem to catch several keys on the keyboard. I've got a utility that I'd like to be able to automagically get a screenshot when something goes
 wrong so I dont have to hope the user can re-create the error. Universal support would be best, but WinXP is the main OS
 I'm not exactly sure what you want here :-) but if you want to capture when the 'Print Screen' key (or any other key) has actually been pressed, try pyHook. Note: pyHook only works on Windows!
 Also note that if you want all of the keypresses, but you _don't_ care about the application with focus receiving the input, you can do a complete key grab using TKInter or
 Pygame, and probably the other GUI packages too. But, like I said, if you were, for example, typing an e-mail and you started a script that did a complete grab like this, you'd no longer be
 able to type into the e-mail window.Using pyHook, your program could see all the keypresses, but they'd also still be sent to the e-mail program. Actually, I've never tried it, but I'm pretty sure that's how the GUI
 packages' key capturing works. You may be asking 'well, it sounds like pyHook does a better job of this anyway!' Yeah, you're right. However, as Alan exclaimed, pyHook works only on Windows!
 So the solution I offered would be more portable. Hope that helps, -Luke 
 ___ Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-04 Thread Luke Paireepinart
I didn't set up a design doc or anything.I just randomly have ideas sometimes and I just make a prototype first so I can see what kind of problems arise,because when I just think about it I can't determine what I will need in order to make the app.
For example, all the functions that I found to do this type of stuff._Yeah, I don't plan ahead.Which is why I might fail my Software Engineering class when I'm a senior.Ah well.I'm in the process of learning how to make requirements sheets and such,
and unit tests. I'm not good at that kind of stuff right at the moment.Well, the long and short of it is,I don't have anything that would be of help to you, except ideas about how things can be done.And the guy who wrote that vnc client probably has thought through all of these things more thoroughly than I have.
One thing I was also trying to make a prototype of, so I could integrate it into the VNC app if I ever got around to it,was a VoIP client/server.I was going to use Speex as the audio codec, and use pyMedia as the microphone input.
The only problem I had was that the pySpeex bindings were only compiled for python 2.2,and I'm trying to get them to compile for 2.4.I installed Visual Studio .net 2003, which is supposedly the compiler they used for python 
2.4,but I still haven't managed to get the kinks worked out well enough for a compile to work.I think the speex guys changed around where all the source codes are located,so I've been trying to re-arrange everything into the directory structure the python compile script expects.
So yeah.If I get that working, the actual VoIP part shouldn't be too hard. pySpeex looks like it should be able to integrate with pyMedia, and pyMedia makes microphone input super-easy.I'm not sure what version of Visual Studio 
2.5 was built with, but if I can get a copy of it, I'll probably try to compile pySpeex for 2.5 also.On 11/4/06, Chris Hengge 
[EMAIL PROTECTED] wrote:Wow, that hasn't come up in my searching, thanks! 
Looks like you are right and the project is dead, but the author did toss there code up for viewing so I can stumble around a bit there. 

On 11/3/06, Jonathon Sisson [EMAIL PROTECTED] wrote:

Chris,I don't know if this has been mentioned yet, but this site might be useful:
http://bdash.net.nz/blog/2003/12/24/python-vnc-client/
The code base has (last I heard) fallen stagnant, but it may very wellbe worth a look as a starting point for your VNC project idea.JonathonChris Hengge wrote: Wow.. I have visions of writing a little wanna-be VNC client/server now
 using the ImageGrab.grab() =D This ImageGrab trick does exactly what I wanted. Thanks for the tip! Actually, I want to write a little package for the learning experience sometime over the holidays (plus I use VNC fairly often), but I can't
 find any direction, or any already made packages for python for the VNC protocol (no libs?). On 11/2/06, *Luke Paireepinart* 
[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote: Anyone know of a way to capture special keys like Print Screen?

 I have a small script to grab all they keycodes, but it doesn't seem to catch several keys on the keyboard. I've got a utility that I'd like to be able to automagically get a screenshot when something goes
 wrong so I dont have to hope the user can re-create the error. Universal support would be best, but WinXP is the main OS
 I'm not exactly sure what you want here :-) but if you want to capture when the 'Print Screen' key (or any other key) has actually been pressed, try pyHook. Note: pyHook only works on Windows!
 Also note that if you want all of the keypresses, but you _don't_ care about the application with focus receiving the input, you can do a complete key grab using TKInter or
 Pygame, and probably the other GUI packages too. But, like I said, if you were, for example, typing an e-mail and you started a script that did a complete grab like this, you'd no longer be
 able to type into the e-mail window.Using pyHook, your program could see all the keypresses, but they'd also still be sent to the e-mail program. Actually, I've never tried it, but I'm pretty sure that's how the GUI
 packages' key capturing works. You may be asking 'well, it sounds like pyHook does a better job of this anyway!' Yeah, you're right. However, as Alan exclaimed, pyHook works only on Windows!
 So the solution I offered would be more portable. Hope that helps, -Luke 
 ___ Tutor maillist-Tutor@python.org 
http://mail.python.org/mailman/listinfo/tutor


___Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-03 Thread Chris Hengge
Wow.. I have visions of writing a little wanna-be VNC client/server now using the ImageGrab.grab() =DThis ImageGrab trick does exactly what I wanted. Thanks for the tip!Actually, I want to write a little package for the learning experience sometime over the holidays (plus I use VNC fairly often), but I can't find any direction, or any already made packages for python for the VNC protocol (no libs?).
On 11/2/06, Luke Paireepinart [EMAIL PROTECTED] wrote:
 Anyone know of a way to capture special keys like Print Screen? I have a small script to grab all they keycodes, but it doesn't seem to catch several keys on the keyboard. I've got a utility that I'd like to
 be able to automagically get a screenshot when something goes wrong so I dont have to hope the user can re-create the error. Universal support would be best, but WinXP is the main OS
 I'm not exactly sure what you want here :-) but if you want to capture when the 'Print Screen' key (or any other key) has actually been pressed, try pyHook. Note: pyHook only works on Windows!
Also note that if you want all of the keypresses, but you _don't_ careabout the application with focusreceiving the input, you can do a complete key grab using TKInter orPygame, and probably the other GUI packages too.
But, like I said, if you were, for example, typing an e-mail and youstarted a script that did a complete grab like this, you'd no longer beable to typeinto the e-mail window.Using pyHook, your program could see all the
keypresses, but they'd also still be sent to the e-mail program.Actually, I've never tried it, but I'm pretty sure that's how the GUIpackages' key capturing works.You may be asking 'well, it sounds like pyHook does a better job of this
anyway!'Yeah, you're right.However, as Alan exclaimed, pyHook works only on Windows!So the solution I offered would be more portable.Hope that helps,-Luke
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-03 Thread Luke Paireepinart
Chris Hengge wrote:
 Wow.. I have visions of writing a little wanna-be VNC client/server 
 now using the ImageGrab.grab() =D
 This ImageGrab trick does exactly what I wanted. Thanks for the tip!

 Actually, I want to write a little package for the learning experience 
 sometime over the holidays (plus I use VNC fairly often), but I can't 
 find any direction, or any already made packages for python for the 
 VNC protocol (no libs?). 
Heh, I was actually writing my own VNC, that's when I ran into the 
ImageGrab function.
I also did something cool, which is :
self.prevscr = self.currscr
self.currscr = ImageGrab.grab().resize((800,600))
   
diff = ImageChops.difference(self.prevscr,self.currscr)

Obviously you need a currscr before you start, which I declared during 
the initialization of the class.
The cool part of this is that the ImageChops difference will return 
black pixels in any area of the screen that hasn't changed.
so you can just send the changed parts over the network (if you have a 
good algorithm to discard the unchanged portions).
Would be much faster than sending the whole screen every frame, obviously.
Not CPU-faster, but network-faster.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-03 Thread Chris Hengge
Oh wow! That is great trick for lowering network requirements. Have you actually implimented that into a working app for test? You could shave a bit more from the bandwidth using that trick if you locked to a specific window for transfer *thinking blinking tray icons etc would get stripped*. How are you doing the intelligent transfer? Did you setup a grid on the screen and only update if gridX has changes? Other then that, are there any resources you can share for getting me started with my own VNC? Or do you by chance have any design docs you created/followed I could review to get an idea of the process for this? I'm thinking I'll probably have to find something in another language and just try to duplicate it with python to get me started. 
On 11/3/06, Luke Paireepinart [EMAIL PROTECTED] wrote:
Chris Hengge wrote: Wow.. I have visions of writing a little wanna-be VNC client/server now using the ImageGrab.grab() =D This ImageGrab trick does exactly what I wanted. Thanks for the tip!
 Actually, I want to write a little package for the learning experience sometime over the holidays (plus I use VNC fairly often), but I can't find any direction, or any already made packages for python for the
 VNC protocol (no libs?).Heh, I was actually writing my own VNC, that's when I ran into theImageGrab function.I also did something cool, which is :self.prevscr = self.currscrself.currscr
 = ImageGrab.grab().resize((800,600))diff = ImageChops.difference(self.prevscr,self.currscr)Obviously you need a currscr before you start, which I declared duringthe initialization of the class.
The cool part of this is that the ImageChops difference will returnblack pixels in any area of the screen that hasn't changed.so you can just send the changed parts over the network (if you have agood algorithm to discard the unchanged portions).
Would be much faster than sending the whole screen every frame, obviously.Not CPU-faster, but network-faster.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-03 Thread Tony Cappellini
Date: Thu, 02 Nov 2006 20:09:59 -0500From: Bill Burns [EMAIL PROTECTED]Subject: Re: [Tutor] Print Screen
To: Chris Hengge [EMAIL PROTECTED]Cc: pythontutor 
tutor@python.orgMessage-ID: [EMAIL PROTECTED]Content-Type: text/plain; charset=ISO-8859-1; format=flowed
pressed, try pyHook. Note: pyHook only works on Windows!To elaborate, pyHook only works on Win2k and later.I had no success with Windows 98
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart
Chris Hengge wrote:
 I posted this in a similar thread a few days ago, and no replies so I 
 think it needs its own listing.

 Anyone know of a way to capture special keys like Print Screen?
 I have a small script to grab all they keycodes, but it doesn't seem 
 to catch several keys on the keyboard. I've got a utility that I'd 
 like to be able to automagically get a screenshot when something goes 
 wrong so I dont have to hope the user can re-create the error. 
 Universal support would be best, but WinXP is the main OS
Why do you need to capture the keypress 'print screen' if you're 
automatically taking screenshots when something goes wrong?

 Thanks.
 

 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
   

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart
Chris Hengge wrote:
 Because I dont know any other way to capture the screen? (In my mind 
 using print screen would be universal) =P
The print screen button doesn't do anything.
It generates a keycode just like any other button on the keyboard.
Windows captures this keypress and interprets it as you wanting a 
screenshot.
There is no inherent operation tied to this specific button that creates 
a screenshot.
So yeah, you could probably go the route of generating a printscreen 
keypress, but
there are much easier ways to do that.
For example,
Install PIL,
then do
  import ImageGrab
  ImageGrab.grab().save('temp.jpg')
That's all there is to it.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart
Chris Hengge wrote:
 Awesome! Thanks again Luke

 How do I capture the keycode for print screen? (now I'm just curious, 
 because like I said, I've got a script that grabs all but maybe half a 
 dozen keys)
Well, how are you doing it now?
That's the important part.

 On 11/2/06, *Luke Paireepinart* [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:

 Chris Hengge wrote:
  Because I dont know any other way to capture the screen? (In my mind
  using print screen would be universal) =P
 The print screen button doesn't do anything.
 It generates a keycode just like any other button on the keyboard.
 Windows captures this keypress and interprets it as you wanting a
 screenshot.
 There is no inherent operation tied to this specific button that
 creates
 a screenshot.
 So yeah, you could probably go the route of generating a printscreen
 keypress, but
 there are much easier ways to do that.
 For example,
 Install PIL,
 then do
  import ImageGrab
  ImageGrab.grab().save('temp.jpg')
 That's all there is to it.



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-02 Thread Terry Carroll
On Thu, 2 Nov 2006, Luke Paireepinart wrote:

   import ImageGrab
   ImageGrab.grab().save('temp.jpg')

I never knew about that.  Thanks, that's pretty cool.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-02 Thread Bill Burns
Chris Hengge wrote:
 I posted this in a similar thread a few days ago, and no replies so I 
 think it needs its own listing.
 
 Anyone know of a way to capture special keys like Print Screen?
 I have a small script to grab all they keycodes, but it doesn't seem to 
 catch several keys on the keyboard. I've got a utility that I'd like to 
 be able to automagically get a screenshot when something goes wrong so I 
 dont have to hope the user can re-create the error. Universal support 
 would be best, but WinXP is the main OS
 

I'm not exactly sure what you want here :-) but if you want to capture
when the 'Print Screen' key (or any other key) has actually been
pressed, try pyHook. Note: pyHook only works on Windows!

Here's some sample code:

code


Captures a press of the 'Print Screen' key.
The following requires ctypes and pyHook.
ctypes is standard in Python2.5.

ctypes - http://sourceforge.net/projects/ctypes/
pyHook - http://www.cs.unc.edu/Research/assist/developer.shtml

from ctypes import windll, byref
from ctypes.wintypes import MSG

import pyHook

user32 = windll.user32

def keyboardEvent(event):
 if event.KeyID == 44: print You hit 'Print Screen'!
 return True

hm = pyHook.HookManager()
hm.KeyDown = keyboardEvent
hm.HookKeyboard()
msg = MSG()
while user32.GetMessageA(byref(msg), None, 0, 0):
 user32.TranslateMessage(byref(msg))
 user32.DispatchMessageA(byref(msg))

/code

HTH,

Bill




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart

 Anyone know of a way to capture special keys like Print Screen?
 I have a small script to grab all they keycodes, but it doesn't seem to 
 catch several keys on the keyboard. I've got a utility that I'd like to 
 be able to automagically get a screenshot when something goes wrong so I 
 dont have to hope the user can re-create the error. Universal support 
 would be best, but WinXP is the main OS

 

 I'm not exactly sure what you want here :-) but if you want to capture
 when the 'Print Screen' key (or any other key) has actually been
 pressed, try pyHook. Note: pyHook only works on Windows!
   
Also note that if you want all of the keypresses, but you _don't_ care 
about the application with focus
receiving the input, you can do a complete key grab using TKInter or 
Pygame, and probably the other GUI packages too.
But, like I said, if you were, for example, typing an e-mail and you 
started a script that did a complete grab like this, you'd no longer be 
able to type
into the e-mail window.  Using pyHook, your program could see all the 
keypresses, but they'd also still be sent to the e-mail program.
Actually, I've never tried it, but I'm pretty sure that's how the GUI 
packages' key capturing works.
You may be asking 'well, it sounds like pyHook does a better job of this 
anyway!'
Yeah, you're right.
However, as Alan exclaimed, pyHook works only on Windows!
So the solution I offered would be more portable.
Hope that helps,
-Luke

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor