sending Ctrl+C to a running program?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

sending Ctrl+C to a running program?

Post by rullbandspelare » Wed Mar 20, 2013 3:32 pm

Hi!
Is it possible to send a Ctrl C to a running program if You know its processID?

I have "cmd" running a command line program. And to stop it it requires that Ctrl + C is pressed or the key x.
It is not running in a visible cmd window.

Thanks for any help!

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Mar 20, 2013 6:47 pm

I think you'll have to setfocus to the window using its name or handle. The window will then become visible. Once the window is visible you should be able to send the keys to it.

Similar to this.

Code: Select all

Let>RP_WINDOWMODE=0
Let>RP_WAIT=0

Run>cmd /k

Wait>2

SetFocus>CMD*
Send>Exit%crlf%

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 20, 2013 8:14 pm

Might be easier to just kill the process?

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Post by rullbandspelare » Thu Mar 21, 2013 5:34 pm

Thanks to both of You for Your input!

1. The first approach seamed promising and worked as long as it is a user that starts the compiled script. In my case it is wepbage with a a php script , like:
exec('compiledscript.exe')

and then i can not get the window to show. It is not even sure that there is a user loged in to the windows machine that runs the Apache webserver..


2. it is not possible to kill it. cos it have to close controlled to render valid result.

I found this program that sends CTRL + c to a program. But it turns out , in my case, that I have to press q to end my program correctly.
http://www.latenighthacking.com/project ... endSignal/

Thanks!

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Post by rullbandspelare » Thu Mar 21, 2013 8:12 pm

just found ObjectSendKeys>5244288,q
That should do it.
Not sure , will test later.

ps.
ObjectSendKeys>
works Perfectly!
ds

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts