Controlling windows gui applications from python
tim
tim.vets at skynet.be
Mon Nov 21 05:45:27 EST 2005
Thanks for this tip, this looks like exactly what I need.
Is there a more extended documentation for watsup somewhere ?
I didn't find info on:
how to send keystrokes to a program.
how to control ComboBox elements...
trying out the examples, here are some problems I am running into:
I tried adapting the example4.py and example4a.py scripts for running an
app of my own and clicking a button.
I commented out everything except for running the application and
clicking a button.
here's what i left in:
###########################
from watsup.launcher import launchApp,terminateApp
from watsup.winGuiAuto import findTopWindows,
findControl,getEditText,clickButton
from watsup.performance import PerformanceCheck,PerformanceCheckError
from time import sleep,time
def main(myExecutable,myWantedText):
# find an instance of SimpleForm. If one isn't there, launch it
forms=findTopWindows(wantedText=myWantedText)
if forms:
form=forms[0]
else:
form=launchApp(myExecutable,wantedText=myWantedText)
button=findControl(form,wantedText='Pref')
sleep(1)
clickButton(button)
#sleep(5)
#terminateApp(form)
if __name__=='__main__':
print ' please run example4a or 4b'
###########################
when I un-comment the line : "terminateApp(form)" i get the following error:
Traceback (most recent call last):
File
"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Python24\Lib\tim_vets\kip\examples\example4a_gnmidi.py", line
3, in ?
main('C:\\tools\\MFiTool3.0_INTL_1.04.00\\MFiTool3.exe','MFi Tool 3')
File "C:\Python24\Lib\tim_vets\kip\examples\example4_gnmidi.py", line
14, in main
button=findControl(form,wantedText='Pref')
File "C:\Python24\lib\site-packages\watsup\winGuiAuto.py", line 327,
in findControl
raise WinGuiAutoError("EnumChildWindows failed with win32gui.error " +
WinGuiAutoError: EnumChildWindows failed with win32gui.error 853268,
wantedText='Pref', wantedClass=None, selectionFunction=None, maxWait=1,
retryInterval=0.1
with this line commented out, getting the 'Pref' button clicked works
sometimes...
most of the times i get something like:
File "example4_gnmidi.py", line 14, in main
button=findControl(form,wantedText='Pref')
File "C:\Python24\lib\site-packages\watsup\winGuiAuto.py", line 327,
in findControl
raise WinGuiAutoError("EnumChildWindows failed with win32gui.error " +
WinGuiAutoError: EnumChildWindows failed with win32gui.error 1442992,
wantedText='Pref', wantedClass=None, selectionFunction=None, maxWait=1,
retryInterval=0.1
Opening the application is the only thing that always works...
thanks!
Simon Brunning wrote:
>On 18/11/05, tim <tim.vets at skynet.be> wrote:
>
>
>>Hi all, I'm almost as new to this list as to python so I hope I don't
>>get a "this has been answered a 100 times before" or anything...
>>
>>Currently I am using a program named 'Macro Scheduler' for automating
>>programs that don't have a command line version.
>>Its a simple scripting language that allows you to automate button
>>clicks, mouse movement, starting programs, checking the state of a
>>window, changing the focus, type text into an input field...etc.
>>Is there a way to do these things from within Python?
>>
>>
>
><http://www.tizmoi.net/watsup/intro.html>
>
>--
>Cheers,
>Simon B,
>simon at brunningonline.net,
>http://www.brunningonline.net/simon/blog/
>
>
>
>
>
More information about the Python-list
mailing list