Terenz Posted December 5, 2013 Posted December 5, 2013 (edited) Hello I don't have found a way to abort a command using prompt command in autoit like CTRL+C in a CMD windows My script: #include <Constants.au3> HotKeySet("{ESC}", "StopCommand") HotKeySet("1", "ReDoCommand") Local $pid $pid = Run(@ComSpec & " /k ", "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($pid, "ping -t www.google.com" & @CRLF) While 1 $msg = StdoutRead($pid) If $msg <> "" Then ConsoleWrite($msg) Sleep(50) WEnd Func ReDoCommand() StdinWrite($pid, "ping -t google.com" & @CRLF) EndFunc Func StopCommand() ConsoleWrite("-STOP HERE" & @CRLF) ;~ $hCmd = WinGetHandle("C:\WINDOWS\system32\cmd.exe") ;~ ControlSend($hCmd, "", "", "^c") EndFunc ControlSend seems don't do nothing P.S. I don't want to use ProcessClose or StdioClose, i want to have one CMD process and give the command to that process and not run-open-close-run-open-close etc. Suggestion? Edited December 5, 2013 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
FireFox Posted December 5, 2013 Posted December 5, 2013 (edited) Hi,You need to send a SIGNAL to the process, in this case SIGINT (in the point of view of UNIX).There is the SendConsoleCtrlHandler function, an example is available >here. But it does not work for your case and I'm not able to tell you why without digging. I suggest you to close the process and start a new one, it's a simple command prompt. Br, FireFox. Edited December 5, 2013 by FireFox
Terenz Posted December 5, 2013 Author Posted December 5, 2013 Cool example but not work for me, i have try it Nothing is so strong as gentleness. Nothing is so gentle as real strength
FireFox Posted December 5, 2013 Posted December 5, 2013 Cool example but not work for me, i have try itBut it does not work for your case...I suggest you to close the process and start a new one, it's a simple command prompt.
Terenz Posted December 5, 2013 Author Posted December 5, 2013 If is possible i prefer to run the process only one time, if not my last chance is respawn cmd everytime. Nothing is so strong as gentleness. Nothing is so gentle as real strength
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