rylorg Posted February 21, 2007 Share Posted February 21, 2007 I'm working on a fairly simple script and i need a little help, I have it set so when it see's a pixel that is a certain color it does some stuff, but the pixel I'm getting lingers and it does the stuff 3 or 4 times in a row. How can i put a "cool down" on it with out pausing the whole script? Link to comment Share on other sites More sharing options...
xcal Posted February 21, 2007 Share Posted February 21, 2007 (edited) Hard to say without seeing your script, but throwing in a little Sleep() probably would do it. Not sure if that'd work for you... depends on what you mean by "with out pausing the whole script." Edited February 21, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
therks Posted February 21, 2007 Share Posted February 21, 2007 Without seeing your script (people think we are telepathic ) I could suggest a variable that gets toggled. I assume you have something like a while loop that continuously checks for the pixel colour, well within your IF statement add in another IF checking variable that you set to TRUE previously, when it hits that IF statement, set the variable to FALSE. Then when the IF for your pixel colour returns true it will skip the second IF until the variable is set back to TRUE, which you do by ELSE'ing off the first IF statement so that when the pixel colour does not exist, it sets the variable back to TRUE. Something like: $b_KeepSearching = true ... While 1 ... If PixelColor(etc) Then If $b_KeepSearching Then $b_KeepSearching = False ...Do your thang... EndIf ElseIf $b_KeepSearching = True EndIf ... WEnd ... My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
CodeMaster Rapture Posted February 21, 2007 Share Posted February 21, 2007 While this is a valid answer: $b_KeepSearching = true ... While 1 ... If PixelColor(etc) Then If $b_KeepSearching Then $b_KeepSearching = False ...Do your thang... EndIf ElseIf $b_KeepSearching = True EndIf ... WEnd ...oÝ÷ Øfk&Þmëmz»hçnqëaz{¦mêè}Æ¥Ëh>,^g h®)ì¢g¬Û¶*'° ݲ)ÜyÊ&¦ë^®Æ«z¶êà¢Z¶fµéî±ëaɶjëh×6 Global $timer_LastPixel = TimerInit() Global Const $Cool_Down = 3000 ;3 seconds While 1 ;Stuff ;More stuff If (TimerDiff($timer_LastPixel) > $Cool_Down) Then If (PixelGetColor($X,$Y) == $Color) Then $timer_LastPixel = TimerInit() ;Do Stuff EndIf EndIf Sleep(1) ;Let's not hog the CPU WEnd Both methods work and don't pause the whole script. I guess it depends on personal preference and situations. -CMR Link to comment Share on other sites More sharing options...
therks Posted February 23, 2007 Share Posted February 23, 2007 "I shall be guided by thee in this" as I have never (not once!) used PixelGetColor for any practical reason. My AutoIt Stuff | My Github 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