Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

StdOutRead broken or what am i doing wrong

$
0
0

I'm not unfamiliar to Autoit obviously but this is baffling me. Is this a bug in StdOutRead?

 

This is a very simple way to see the GUID of your power settings on a laptop but its not working as long as it's inside an IF conditional.

Local $foo = Run(@ComSpec & " /c powercfg -getactivescheme", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1     $line = StdoutRead($foo)     If @error Then ExitLoop     If StringInStr($line, "GUID") Then         MsgBox(0, "STDOUT read:", $line)     EndIf WEnd

The message should show: Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)

But it's only coming back with a partial string Power Scheme GUID:

 

If you remove the condition IF statement and just leave the msgbox line by itself on the 2nd iteration it will show the entire string. 

 

Now if you do this code below, you can see it going through 2 iterations, which it should, so I use another msgbox to show that.  If you also put another msgbox line out side of that then you get 2 iterations and 3 msgboxes(in the real script I won't be using msgbox, it will be a variable.)

Local $foo = Run(@ComSpec & " /c powercfg -getactivescheme", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1     $line = StdoutRead($foo)     If @error Then ExitLoop     If StringInStr($line, "GUID") Then         MsgBox(0, "STDOUT read:", $line)     EndIf     MsgBox(0, "STDOUT read:", $line) WEnd

I use the conditional so I can capture that string on the iteration that contains GUID. But it doesn't work as long as its in side the IF statement and only shows the partial string. 

 

Anyone have any ideas why it's acting so weird?

 

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>