473,513 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

Aug 11 '05 #1
4 5719
ina
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


Aug 11 '05 #2
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

Aug 12 '05 #3
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
Aug 12 '05 #4
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

Aug 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
18089
by: Noah | last post by:
Does anyone have a function to convert back and forth between NT style paths and POSIX style? It seems trivial, but I want to make sure I don't overlook some obscure detail. Is it a simple matter...
3
4501
by: David Isal | last post by:
hi all, i'm new to python and i'm trying to build a python extension on win98, written in c++, with cygwin. but i keep having the same error message, and i didnt't find much resources on the web...
35
7717
by: Vamsi Mudrageda | last post by:
I am kind of new to Python, and after trying and using wxPython, I found it kind of lacking in easy-to-read documentation, speed at loading, and GUI response-time. So I am looking for an another...
8
3759
by: Jonathan Polley | last post by:
I have one account on a WindowsXP machine that refuses to run IDLE (or any other python script that uses Tk). Other people can login to that PC and IDLE runs just fine, so it is not an...
7
8935
by: barney | last post by:
I'm trying to write to an existing file under windows XP (home). The files are in 'My Music' which I think may be treated in some special way under XP. The relevant python code is as follows: ...
3
16718
by: Abby | last post by:
I'm now using Cygwin as my compiler for C code. I use Dev-c++ as my editor. The reason why I chose Cygwin compiler instead of the compiler that came with Dev-C++ is that I believe it uses the same...
53
5278
by: noahmd | last post by:
Okay, once-upon-a-time I tried to start programming by learning C. At the time I was younger and didn't really understand all that C had to offer. I eventually moved over to Microsoft's Visual...
5
13293
by: mzdude | last post by:
I've just started playing with Python. Installed 2.5 on Windows XP system. I'm working through some of the examples in Programming Python 3ed by Mark Lutz. Given the following example when the Quit...
9
16113
by: Larry Hale | last post by:
I've heard tell of a Python binding for libmagic (file(1) *nixy command; see http://darwinsys.com/file/). Generally, has anybody built this and worked with it under Windows? The only thing I've...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.