Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to quit a Windows GUI program gracefully with Python under Cygwin?

Reply
Thread Tools

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

 
 
KB
Guest
Posts: n/a
 
      08-11-2005
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

 
Reply With Quote
 
 
 
 
ina
Guest
Posts: n/a
 
      08-11-2005
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


 
Reply With Quote
 
 
 
 
KB
Guest
Posts: n/a
 
      08-12-2005
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

 
Reply With Quote
 
Jason Tishler
Guest
Posts: n/a
 
      08-12-2005
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
 
Reply With Quote
 
KB
Guest
Posts: n/a
 
      08-13-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: exit a program gracefully Gabriel Genellina Python 1 05-05-2009 11:28 AM
close GUI and quit script? globalrev Python 2 04-20-2008 11:08 PM
gracefully terminate a JVM on windows if can't ctrl-c shell Michael Grove Java 3 06-14-2005 01:07 AM
[PY GUI] interest function in python GUI(wxpython,pyqt) program.wxpython,pyqt ulysses Python 4 10-22-2003 03:28 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57