Quiting a Windows GUI program gracefully with a Python script under Cygwin?



Hi,

My question may sound naive or rudimentary to expert Windows
programmers. I don't know anything about Visual Basic, MSDN, or MFC,
nor do have time to learn any of them. (I am an intermediate Python
user, immigrating from the Unix/Linux world.)

I want to write a Python script that controls and automates a Windows
GUI computation program with no command-line control.

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.

Following the advice of a Python expert, I tried 'SendKeys' Python
module with a 'Alt-F4' key combination. Of course, the 'Alt-F4'
terminates the application gracefully if I press the keyboard directly,
but it doesn't work inside a Python script.

What occurs to my mind is that there must be native Windows library
calls to do what I want, and that there might be a Python binding to
them.

Any suggestions would be appreciated.

Thanks,

KB

.