Jump to content

Recommended Posts

Posted

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"?

Posted

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!)

Posted

thanks for your help anyways

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

  • Moderators
Posted

$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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...