How to quit a Windows GUI program gracefully with Python under Cygwin?

K

KB

Hi,

I want to write a Python script that controls and automates a Windows
GUI computation program.

My problem is that I do not know how to quit the Windows GUI program
gracefully with a command (program's or Python) in Cygwin. 'kill' or
CTRL-C command in Cygwin does not finish it gracefully, meaning that
some outputs do not come out normally. The only thing I know is to
click 'File-Exit' menu, but
this requires a manual intervention that prevents scripting.

Is there a way to quit a Windows GUI program gracefully with Python
under Cygwin, of course, after the program finishes
normal execution?

Thanks,

KB
 
I

ina

Send the active program an alt-f4. I do this through shell.send keys.
Hope this was of help.
 
K

KB

Thanks.

After I confirmed 'Alt-F4' would terminate and close a win32
application running independently,
I installed 'SendKeys' module and tested with the following code under
both Cygwin and Python Windows

import os, SendKeys
os.system('program datafile')
SendKeys.SendKeys("""
{PAUSE 0.25}
%{F4}
""")

What happened was that the 'program' ran correctly, but it stayed, not
closing the window
under Cygwin and Python Windows. So it seems to me that this does not
work.

One more thing: How do I control the pause time if I do not know the
execution
time of an application?

Thanks in advance.

KB
 
J

Jason Tishler

After I confirmed 'Alt-F4' would terminate and close a win32
application running independently,
I installed 'SendKeys' module and tested with the following code under
both Cygwin and Python Windows

If you installed the SendKeys binary, then it will not work with Cygwin
Python since it is a Windows Python shared extension module. It may be
possible to port SendKeys to Cygwin. Unfortunately, this may not solve
your problem... :,(

Jason
 
K

KB

Of course, I downloaded the source of 'SendKeys' and installed it under
both Cygwin and Python Windows with

$ python setup.py install

although this did not help me.

KB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top