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

Discussion in 'Python' started by KB, Aug 11, 2005.

  1. KB

    KB Guest

    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
     
    KB, Aug 11, 2005
    #1
    1. Advertisements

  2. KB

    ina Guest

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

    KB wrote:
    > 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
     
    ina, Aug 11, 2005
    #2
    1. Advertisements

  3. KB

    KB Guest

    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
     
    KB, Aug 12, 2005
    #3
  4. Re: How to quit a Windows GUI program gracefully with Python underCygwin?

    On Fri, Aug 12, 2005 at 03:07:02AM -0700, KB wrote:
    > 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

    --
    PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
    Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6
     
    Jason Tishler, Aug 12, 2005
    #4
  5. KB

    KB Guest

    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
     
    KB, Aug 13, 2005
    #5
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Grove
    Replies:
    3
    Views:
    8,025
    Michael Grove
    Jun 14, 2005
  2. alex
    Replies:
    1
    Views:
    672
    Christopher Benson-Manica
    Apr 16, 2004
  3. ulysses
    Replies:
    4
    Views:
    1,073
    Werner Schiendl
    Oct 22, 2003
  4. globalrev

    close GUI and quit script?

    globalrev, Apr 20, 2008, in forum: Python
    Replies:
    2
    Views:
    350
    Michael Torrie
    Apr 21, 2008
  5. Gabriel Genellina

    Re: exit a program gracefully

    Gabriel Genellina, May 4, 2009, in forum: Python
    Replies:
    1
    Views:
    386
    Lawrence D'Oliveiro
    May 5, 2009
  6. Joana
    Replies:
    4
    Views:
    1,150
    Joshua Kugler
    May 26, 2009
  7. Mojca Miklavec

    ruby under cygwin & windows paths

    Mojca Miklavec, Jan 13, 2006, in forum: Ruby
    Replies:
    15
    Views:
    434
    Mojca Miklavec
    Jan 18, 2006
  8. Jabba Laci
    Replies:
    0
    Views:
    291
    Jabba Laci
    Mar 22, 2014
Loading...