[Tutor] keystroke via software

Alan Gauld alan.gauld at btinternet.com
Mon Jul 10 01:45:22 CEST 2006


> How can one make a networked Windows XP
> think a keystroke has been made every 13 minutes?

I've never done it over a network but I have done it in Delphi.

The API function you need is:

PostMessage(hwnd, idMessage, wParam, lParam)

Post a message to a window.


Parameters

hwnd : int The hWnd of the window to receive the message.
idMessage : int  The ID of the message to post.
wParam : int The wParam for the message
lParam : int The lParam for the message

> What would a python program to do this look like?

Like I say I've never tried it from Python, but you need to
find a way to getb the handle of the window to which you
want to post the message. A tool like WinSpy will provide that info.

The Keypress messages are all defined in the API reference
material, there are subtle differences so check the docs.

Finally the wparam/lparams will depend on the actual
message you choose, aghain refer to the docs. BBut in
theory its a case of importing the win32 modules and
sending the message wiith a 15 second sleep() in between...

HTH,

Alan G. 





More information about the Tutor mailing list