Scripting Windows GUI application with Python (SendKeys)

Paul Prescod paul at prescod.net
Mon May 17 20:57:57 EDT 1999


Christian Lemer wrote:
> 
> Dear all,
> 
> Currently we use WinBatch to automate some tests and productions
> application under Windows NT.
> 
> One year ago, we switched from Perl to Pyton as script language under
> unix.
> 
> I wonder if it is possible to drive a Windows GUI application (using
> keybord commands) like it is possible in Winbatch with Python under
> Windows?
> 
> I installed also the windows extensions but couldn't find the correct
> way to send a key to an application.

I don't have nice code to share but I can give a hint:

The SendMessage command on window objects can be used to send any window
message to any window. That includes the "WM_CHAR" and "WM_COMMAND"
message. This is really difficult stuff, though, because Windows apps are
not nearly as deterministic as you would like them to be. 
-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for only himself
 http://itrc.uwaterloo.ca/~papresco

The dress code in Las Cruces New Mexico has been tightened [to] target 
Gothic clothing, such as dark trench coats. "It is not a witch hunt"
Superintendent Jesse L. Gozales said. "It is for the safety of the kids
in our schools."  - Associated Press, May 16 1999




More information about the Python-list mailing list