Jump to content
Sign in to follow this  
phew

CMD.EXE returns a string

Recommended Posts

phew

hi,

i got a console program written in c++, telling me something about the hardware of the computer.

to automate it i wrote a little autoitscript that just executes this c++ program (getstat.exe). but now i want it to "interact" with this:

so when the "getstat.exe" is executed it returns some strings and then "YES" or "NO" in the last line of the cmd.exe-window,

so if it returns "YES" i want my autoitscript to write "getstat.log" with all of the cmd.exe-windows content, if it returns "NO" i want it to do nothing.

the problem is, how to read the returned text from the "cmd.exe-window"?

Share this post


Link to post
Share on other sites
phew

but how do i read out exactly one line and write it to the getstat.log?

the getstat.exe returns:

line1

line2

...

enabled: YES

...

lineN

now i want to read out the whole line "enabled: YES" if it matches "YES", "enabled: NO" if it matches "NO" etc.,

i tried with StringInStr() but actually i did not get it working.

help again, please

(the line number is always the same, 16!)

Share this post


Link to post
Share on other sites
phew

thanks for your help anyways

i'm sure someone else will answer this, that is the forum for - to learn from each other :)

Share this post


Link to post
Share on other sites
phew

k got it,

StringTrimLeft()

and

StringTrimRight() / StringTrimMid

:-)

Share this post


Link to post
Share on other sites
SmOke_N

$iPID = Run("getstat.exe", "", @SW_HIDE, 2)

Local $aArray, $sLine
While 1
    $sLine &= StdoutRead($iPID)
    If @error Then ExitLoop
    $aArray = StringRegExp($sLine, "(?s)(?i)(Enabled: \w+)", 1)
    If IsArray($aArray) Then ExitLoop
Wend
If IsArray($aArray) Then 
    MsgBox(0, "Found", $aArray[0])
Else
    MsgBox(16, "Error", "Not Found")
EndIf


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Blue_Drache

You cheated with RegExp(). :)


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×