weltee Posted June 7, 2007 Share Posted June 7, 2007 Hello autoit community,i have a small problem in driving an external calculation application. This application Dos application launches a cmdtool with a specific title let's say :"MY SIMULATOR"In this cmd tool window numerous texts are written and would like to detect the text "calculation finished" or "calculation aborted".i am not able to reroute the output of the cmdtool so i have to check it's contentso i need a function to check or survey dynamically the content of a specific cmdtool (presence of a specific text) because these sentences may appear 2 mns or 5 hours later.(there are solutions in other windows but i need help for the content of a cmd tool)the final target is to switch automatically on a specific behavoiur depending on the result written by the calculation in the cmdtool.i am on XPby advance thanks for your help Link to comment Share on other sites More sharing options...
MadBoy Posted June 7, 2007 Share Posted June 7, 2007 (edited) #include <array.au3> Global $ApplicationRunOutput Global $Application_To_Run = "dir" ; program that is executed $ApplicationRun = Run(@ComSpec & " /c " & $application_to_run, '', @SW_HIDE, 2) ; runs that application While 1 $ApplicationRunData = StdoutRead($ApplicationRun) ; Reads output from $ApplicationRun If @error Then ExitLoop If $ApplicationRunData Then $ApplicationRunOutput &= $ApplicationRunData Else Sleep(10) EndIf WEnd $ApplicationRunOutput = StringStripWS($ApplicationRunOutput, 6) ; Remove spaces from output $ApplicationRunOutput = StringSplit($ApplicationRunOutput, @CRLF) ; Split output of whatever your CMD windows spits out _ArrayDisplay($ApplicationRunOutput) ; Shows you what's in array (what your command windows spitted out) ; Then go thru array and search for the string you want to search However i am not sure if the output is instant or it needs program to actually finish. Edited June 7, 2007 by MadBoy My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 7, 2007 Share Posted June 7, 2007 That code would need to be modified to check for it on every loop. I don't think the program is ending because otherwise he could just RunWait(). Link to comment Share on other sites More sharing options...
MadBoy Posted June 7, 2007 Share Posted June 7, 2007 That code would need to be modified to check for it on every loop. I don't think the program is ending because otherwise he could just RunWait(). You're right I added MsgBox into text. That's where you gotta play with code is my best guess. #include <array.au3> Global $ApplicationRunOutput Global $Application_To_Run = "dir" ; program that is executed $ApplicationRun = Run(@ComSpec & " /c " & $application_to_run, '', @SW_HIDE, 2) ; runs that application While 1 $ApplicationRunData = StdoutRead($ApplicationRun) ; Reads output from $ApplicationRun If @error Then ExitLoop If $ApplicationRunData Then $ApplicationRunOutput &= $ApplicationRunData MsgBox(0,0, $ApplicationRunOutput) ; Here's where you gotta try to do some 'coding' to get instant values. Else Sleep(10) EndIf WEnd $ApplicationRunOutput = StringStripWS($ApplicationRunOutput, 6) ; Remove spaces from output $ApplicationRunOutput = StringSplit($ApplicationRunOutput, @CRLF) ; Split output of whatever your CMD windows spits out _ArrayDisplay($ApplicationRunOutput) ; Shows you what's in array (what your command windows spitted out) My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
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