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


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

Any suggestions would be appreciated.




Relevant Pages

  • Re: Installing WebDAV server
    ... sh-based UNIX/Linux shell prompt). ... But never with Python, so I hadn't got a clue about the prompt. ... OSes have command shells, too, you know; they are just named and run ... Look for the Windows version. ...
  • Re: ann: servicestation - run your linux/mac services on windows without needing pywin...
    ... isn't written in Python, I did write it with python in ... released under the CDDL license. ... on windows, but don't want to learn much/anything about windows service ... Monitoring the command its running and keeping it alive. ...
  • Re: newbie question
    ... Python is fun and it's easier to use a real OS to develop the programs, ... Grant it I am a command line junky, ... "The script can be given a executable mode, or permission, using the ... the above seems to me like you are useing windows. ...
  • RE: Using command line args on Windows
    ... Go to a command prompt. ... type python and you have the command line shell you know and love. ... Using command line args on Windows ...
  • Re: need help with python
    ... Python and can't get things to run, ... That is one of my problems, I don't know exactly how the whole command ... I know how to do file paths and stuff but I'm not sure what to ... It sounds like a Windows tutorial would not be wasted time for you, ...