tony Posted May 14, 2009 Posted May 14, 2009 Hello, I want to send a CTRL+C signal to a process. This process doesn't have a window. It is just an executable. I identify the process that is running using this code, but I want to send a control+c. If I do a ProcessClose the process doesn't save its data correctly. This is what I am using to find the process: $list = ProcessList("cp_detect.exe") for $i = 1 to $list[0][0] msgbox(0, $list[$i][0], $list[$i][1]) ProcessClose("cp_detect.exe") next Any idea? Thanks tony
toonboon Posted May 14, 2009 Posted May 14, 2009 how the hell can you send a control C if there is no window to select text in? or am I stupid on this one? [right]~What can I say, I'm a Simplistic person[/right]
PsaltyDS Posted May 14, 2009 Posted May 14, 2009 Hello, I want to send a CTRL+C signal to a process. This process doesn't have a window. It is just an executable. I identify the process that is running using this code, but I want to send a control+c. If I do a ProcessClose the process doesn't save its data correctly. This is what I am using to find the process: $list = ProcessList("cp_detect.exe") for $i = 1 to $list[0][0] msgbox(0, $list[$i][0], $list[$i][1]) ProcessClose("cp_detect.exe") next Any idea? Thanks tony In normal (not scripted) operation, how do you close it while saving data? Is it a console app (running in a "DOS box" similar to Telnet.exe)? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Richard Robertson Posted May 14, 2009 Posted May 14, 2009 Send just presses keys. It doesn't require a target. You are stupid on this one.
tony Posted May 14, 2009 Author Posted May 14, 2009 Send just presses keys. It doesn't require a target. You are stupid on this one. It is a process created from the command line using a perl script. The process is spawnd by the perl script. Once the main script returns, this child process remains active.If the program (cp_detect.exe) is run from the command line I can manually do CRTL+C and everythnig works fine. I am trying to automate this by running from perl using a system() function. Another program needs to be run as a parent from the same script. Once this other program is done, I need to close my cp_detect.exe.tony
Richard Robertson Posted May 14, 2009 Posted May 14, 2009 Oh. Control C in a command prompt is actually similar to firing an error in the executing program. It is designed to halt it.
anixon Posted May 14, 2009 Posted May 14, 2009 Hello, I want to send a CTRL+C signal to a process. This process doesn't have a window. It is just an executable. I identify the process that is running using this code, but I want to send a control+c. If I do a ProcessClose the process doesn't save its data correctly. This is what I am using to find the process: $list = ProcessList("cp_detect.exe") for $i = 1 to $list[0][0] msgbox(0, $list[$i][0], $list[$i][1]) ProcessClose("cp_detect.exe") next Any idea? Thanks tony This is an option CODE;//Alt+Keys Monitor: Func _KeysMonitor() $dll = DllOpen("user32.dll") ;//Alt+C Switch If _IsPressed('12', $dll) And _IsPressed('43', $dll) Then DllClose($dll) _yourfunction() EndIf DllClose($dll) EndFunc ;==>_KeysMonitor Cheers Ant..
tony Posted May 14, 2009 Author Posted May 14, 2009 Sorry but this suggestion is not clear. Could you elaborate on that? How can I use the 'yourfunction'? Thanks tony
JRowe Posted May 14, 2009 Posted May 14, 2009 yourfunction() func yourfunction() msgbox(0,"Hi There", "I'm a messagebox called by yourfunction()") endfuncCheck out AutoIt 1-2-3.That should walk you through the basics of the language, and get you on your feet to the point where the Help File can answer your questions a lot more quickly than the forum. Good luck! [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center]
anixon Posted May 14, 2009 Posted May 14, 2009 yourfunction() func yourfunction() msgbox(0,"Hi There", "I'm a messagebox called by yourfunction()") endfunc Check out AutoIt 1-2-3. That should walk you through the basics of the language, and get you on your feet to the point where the Help File can answer your questions a lot more quickly than the forum. Good luck! That was a good reply by way of explaination func yourfunction() is a subroutine of the code which continually looks for the user pressing Ctrl+C so whatever you want Ctrl+C to do is what you put in the routine called. The nameing yourfunction() was simply for explaination purposes. You can call it what ever you want many coders use the Func _yourroutine() "note the '_'" for reasons better understood as your skills with this language develop. Dont forget that you can pass values to the sub routine by including them in the call for example yourfunc(6,12) on the subroutine side the values to be passed are given a variable Func yourfunction($value1, $value2) in this case the $value1 variable is 6 and the $value2 variable is 12. Variables can be Local, Global etc. Good luck with your project Ant..
TurionAltec Posted May 15, 2009 Posted May 15, 2009 (edited) Can the perl script send anything to the Stdin of cp_detect.exe ? If so, before terminating the perl script, you can send Ctrl+C to all the child processes. If not you can call your script, which will call cp_detect.exe using run() and hooking up to the Stdin of the process, then either: -wait for the parent process (the perl script) to end, then send Ctrl+C to the process's stdin -Wait for some other external process to try and close the Autoit script, then send Ctrl+C to the process. Are you reading any information from Stdout in the process in perl? FYI CTRL+C is ACSII code 03 Edited May 15, 2009 by TurionAltec
tony Posted May 19, 2009 Author Posted May 19, 2009 I figured out how to accomplish that. I send a CTRL+C to the cmd.exe that is open and that does the trick. her is the code that seems to work: $list = ProcessList("cmd.exe") for $i = 1 to $list[0][0] WinActivate("cmd.exe", "") ; Send ("^c") next Thanks all for your help. tony
martin Posted May 19, 2009 Posted May 19, 2009 I figured out how to accomplish that. I send a CTRL+C to the cmd.exe that is open and that does the trick. her is the code that seems to work: $list = ProcessList("cmd.exe") for $i = 1 to $list[0][0] WinActivate("cmd.exe", "") ; Send ("^c") next Thanks all for your help. tony A bit late to make a suggestion maybe but here goes. Waiting for "cmd.exe" could be a problem because there is no guarantee that there is only one running. If you include in the start up somehow a command "Title someunique19876name" then the command window you are interested in will have a unique name and you can Winactivate the correct window. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
TripleDES Posted May 21, 2009 Posted May 21, 2009 Send("^c")?Thanks. I was about to pull my hair out!!
akshay Posted May 23, 2009 Posted May 23, 2009 hey i hav a similar problem i am automating my ping process but the problem is that i run my ping like this CODE$cmd = Run(@ComSpec & " /c ping " & $ipadd &" -t",@AppDataDir,@SW_HIDE, 0x2 + 0x4 + 0x1 ) now when the program exits the ping process still continues which should no happen it happens because i have given "-t" parameter. i also need it because i want it to run till my program is running so how can i close this process???? ProcessClose() Does Not word
PsaltyDS Posted May 23, 2009 Posted May 23, 2009 (edited) hey i hav a similar problem i am automating my ping process but the problem is that i run my ping like this $cmd = Run(@ComSpec & " /c ping " & $ipadd &" -t",@AppDataDir,@SW_HIDE, 0x2 + 0x4 + 0x1 ) now when the program exits the ping process still continues which should no happen it happens because i have given "-t" parameter. i also need it because i want it to run till my program is running so how can i close this process???? ProcessClose() Does Not word What process did you try to close? ProcessClose($cmd) should work. Oops. ProcessClose("ping.exe") should work. Edited May 23, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
herewasplato Posted May 23, 2009 Posted May 23, 2009 @akshay PsaltyDS gave you to ProcessClose solution. I would like to mention that you can launch the ping app without @ComSpec $cmd = Run("ping " ...... :-) [size="1"][font="Arial"].[u].[/u][/font][/size]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now