Re: Sending CTRL-C event to console application



On Feb 8, 9:12 pm, "Gabriel Genellina" <gagsl...@xxxxxxxxxxxx> wrote:
En Thu, 08 Feb 2007 15:54:05 -0300, Daniel Clark <djbcl...@xxxxxxxxx>
escribió:
I have a Windows command line based application that only shuts down
cleanly if it sees "CTRL-C" on the console. I need to automate the
running of this application, but still allow the user sitting at the
machine to cancel the process cleanly if he/she needs to. In Unix this
would be a tiny shell script that used "kill -15", but under Windows
there does not seem to be an easy way to do this, at least that I can
find.

Below is a test program, based on CreateProcess.py from "Python
Programming on Win32". The
win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pid) lines
don't seem to do anything. What they should do is nothing in the case
of notepad, and exit out of the dir builtin process in the case of the
cmd.exe process.

Any ideas on how to make this work?

From your process creation code:

CreationFlags = win32process.CREATE_NEW_CONSOLE | \
win32process.CREATE_NEW_PROCESS_GROUP | \
win32process.NORMAL_PRIORITY_CLASS

Fromhttp://msdn2.microsoft.com/en-us/library/ms683155.aspx
"Only those processes in the group that share the same console as the
calling process receive the signal. In other words, if a process in the
group creates a new console, that process does not receive the signal, nor
do its descendants."

Thanks, although I'm 99% sure I've also tried it without
CREATE_NEW_CONSOLE (with a process that should just die if sent CTRL-
C, so it was monitorable via Task Manager) and it still didn't work.

I'm going to try taking a different approach by using a GUI Automation
tool like WATSUP [1] or pywinauto[2] next.

Maybe you have better luck on a Windows programming group, asking how to
send a Ctrl-C event (or a SIGINT signal) to another process attached to a
different console.

From what I've found via Google [3], Windows has no real concept of
signals, and no equivalent to SIGINT.

[1] WATSUP - Windows Application Test System Using Python
http://www.tizmoi.net/watsup/intro.html

[2] pywinauto - Python Win32 Automation
http://www.openqa.org/pywinauto/

[3] how to send a SIGINT to a Python process?
http://mail.python.org/pipermail/python-list/2005-October/343461.html

.



Relevant Pages

  • FS - MCI 500 series console modules
    ... That's 32 modules and some master modules that I need to get rid ... Some modules have P&G faders and Aphex VCAs (it's an automated console ... I still have a bag of extra new switches (mostly 12 ... There are two power supplies and an Automation power supply. ...
    (rec.audio.pro)
  • Re: SSL 5000
    ... Why is it a bad console to learn studio maintenance and management ... for recording, editing, and, to a certain extent, automation. ... channel strip, so you'll hear playback with all of your channel tweaks. ...
    (rec.audio.pro)
  • Re: NetView Automation of Console Message
    ... I used to work in the z/OS design organization, but since that has been folded ... console business) was my first big console design effort. ... I've been involved with NetView pretty much ever since. ... folded into System Automation as the Processor Operations sub-component). ...
    (bit.listserv.ibm-main)
  • Re: low/mid priced used consoles
    ... There's no automation, but in this day of DAW systems where you can make ... Also note that it's a line console, so there are no preamps. ... C'est suisse, et tres, tres precis." ...
    (rec.audio.pro)
  • Re: clear shell screen
    ... How To Performing Clear Screen in a Console Application ... The following function is my Python translation of the ... csb.FillConsoleOutputCharacter(u' ', size, TopLeft) ...
    (comp.lang.python)