smcombs Posted September 7, 2009 Share Posted September 7, 2009 Ok I have a while loop that I need to find out which statement it has exited with. Or rather which statement became false. Here is my code:While PixelGetColor(584,738,$kung) Or TimerDiff($timer) < 5000 ;code that needs to be executed while top values are still trueWendHow do I find out if PixelGetColor(584,738,$kung) made the loop exit out, Or TimerDiff($timer) < 5000 made the loop exit out.Thanks for your help Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 7, 2009 Moderators Share Posted September 7, 2009 Create variables that tell you true or false? 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. Link to comment Share on other sites More sharing options...
smcombs Posted September 7, 2009 Author Share Posted September 7, 2009 Can you give me an example of how i would do this? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 7, 2009 Moderators Share Posted September 7, 2009 Sure: Global $f_pixel_exit = False Global $f_timer_exit = False While 1 If Not PixelGetColor(584,738,$kung)Then $f_pixel_exit = True ExitLoop EndIf If TimerDiff($timer) >= 5000 Then $f_timer_exit = True ExitLoop EndIf Sleep(250) WEnd 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. Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 7, 2009 Share Posted September 7, 2009 Ok I have a while loop that I need to find out which statement it has exited with. Or rather which statement became false. Here is my code: [/code] While PixelGetColor(584,738,$kung) Or TimerDiff($timer) < 5000 ;code that needs to be executed while top values are still true Wend How do I find out if PixelGetColor(584,738,$kung) made the loop exit out, Or TimerDiff($timer) < 5000 made the loop exit out. Thanks for your help[/quote] Either your script logic or your description is broken. It can only exit the loop if the pixel is black (returns 0) [b]AND[/b] the timer is >= 5000. Perhaps you meant: [code]While PixelGetColor(584,738,$kung) And TimerDiff($timer) < 5000 ;code that needs to be executed while top values are still true Wend If PixelGetColor(584, 738, $kung) Then ; Exited on TimerDiff() >= 5000 Else ; Exited on PixelGetColor() = 0 (black) EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
wolf9228 Posted September 7, 2009 Share Posted September 7, 2009 (edited) Ok I have a while loop that I need to find out which statement it has exited with. Or rather which statement became false. Here is my code: While PixelGetColor(584,738,$kung) Or TimerDiff($timer) < 5000 ;code that needs to be executed while top values are still true Wend How do I find out if PixelGetColor(584,738,$kung) made the loop exit out, Or TimerDiff($timer) < 5000 made the loop exit out. Thanks for your help $kung = GUICreate("My GUI") GUISetState(@SW_SHOW) Dim $pixelscolor = 0 , $begin = TimerInit() , $BOOL = True While (PixelGetColor(100,100,$kung) <> $pixelscolor And TimerDiff($begin) < 5000) Wend MsgBox(0,"", "PixelGetColor = " & _ PixelGetColor(100,100,$kung) & @CRLF & "pixelscolor = " & $pixelscolor & @CRLF _ & "TimerDiff = " & TimerDiff($begin) & @CRLF & "Timer = " & 5000 ) or $kung = GUICreate("My GUI") GUISetState(@SW_SHOW) Dim $pixelscolor = 15791353 , $begin = TimerInit() , $BOOL = True While (PixelGetColor(100,100,$kung) <> $pixelscolor And TimerDiff($begin) < 5000) Wend MsgBox(0,"", "PixelGetColor = " & _ PixelGetColor(100,100,$kung) & @CRLF & "pixelscolor = " & $pixelscolor & @CRLF _ & "TimerDiff = " & TimerDiff($begin) & @CRLF & "Timer = " & 5000 ) Success: Returns decimal value of pixel's color. Failure: Returns -1 if invalid coordinates. or if invalid coordinates. $kung = GUICreate("My GUI") GUISetState(@SW_SHOW) Dim $pixelscolor = -1 ;if invalid coordinates Dim $begin = TimerInit() While (PixelGetColor(100,100,$kung) <> $pixelscolor And TimerDiff($begin) < 5000) Wend MsgBox(0,"", "PixelGetColor = " & _ PixelGetColor(100,100,$kung) & @CRLF & "pixelscolor = " & $pixelscolor & @CRLF _ & "TimerDiff = " & TimerDiff($begin) & @CRLF & "Timer = " & 5000 ) Edited September 8, 2009 by wolf9228 صرح السماء كان هنا 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