Dgameman1 Posted September 12, 2011 Posted September 12, 2011 I want my script to wait until a color appears before doing anything else using pixelsearch?
sleepydvdr Posted September 12, 2011 Posted September 12, 2011 Never worked with PixelSearch before, but I think something like this would probably do it: Do PixelSearch(blah blah blah) Until Pixelsearch(blah blah blah) NOT @error Dgameman1 1 #include <ByteMe.au3>
Dgameman1 Posted September 12, 2011 Author Posted September 12, 2011 Never worked with PixelSearch before, but I think something like this would probably do it: Do PixelSearch(blah blah blah) Until Pixelsearch(blah blah blah) NOT @error Works perfectly thank you. Now, is it possible to make it until for the color to appear FOR a certain amount of time, and if it doesn't appear within that amount of them, then it just continues through the thread instead of endlessly waiting?
LurchMan Posted September 12, 2011 Posted September 12, 2011 (edited) Add a timer: $ExitTime = 5000 ;In Miliseconds, 5 seconds $Time = TimerInit () Do PixelSearch(blah, blah, blah) Until PixelSearch(blah, blah, blah) Not @Error Or TimerDiff($Timer) >= $ExitTime Edited September 12, 2011 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.
sebgg Posted September 12, 2011 Posted September 12, 2011 this should work $start = timerinit() Do PixelSearch(blah blah blah) $diff = timerdiff ($start) Until Pixelsearch(blah blah blah) NOT @error OR $diff > 10000 ;(10 seconds or 10,000 miliseconds, change this number for delay. sebs Dgameman1 1 GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size
Dgameman1 Posted September 13, 2011 Author Posted September 13, 2011 I have a problem This is my code $start = timerinit() Do $coord=PixelSearch ( 157, 98, 225, 146, 0x545453 , 0 , 1, "" ) $diff = timerdiff ($start) Until not @error OR $diff > 10000 MouseMove ( $coord[0], $coord[1] ) msgbox(32,"gtfds","gfds") And it just ends about a second after I run it. What's the problem?
Blue_Drache Posted September 13, 2011 Posted September 13, 2011 Do If Not WinActive($hwnd_Window) Then WinActivate($hwnd_Window) WinWaitActive($hwnd_Window) EndIf GUI() Sleep(5) $aPosition = PixelSearch($Left, $Top, $Right, $Bottom, $Red, $RedColorSensitivity, 3) CheckTimer(@error) Until @error <> 1 If IsArray($aPosition) Then MouseMove($aPosition[0] + Random(-5, 5, 1), $aPosition[1] + Random(-3, 3, 1), 5) $SLeft = $aPosition[0] - 50 $SRight = $SLeft + 60 $STop = $aPosition[1] - 50 $SBottom = $STop + 65 EndIf Func CheckTimer($PixelError) If TimerDiff($Timer) >= $MaxTime Then SetError(0) Return -1 EndIf SetError($PixelError) EndFunc ;==>CheckTimer Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Dgameman1 Posted September 13, 2011 Author Posted September 13, 2011 Do If Not WinActive($hwnd_Window) Then WinActivate($hwnd_Window) WinWaitActive($hwnd_Window) EndIf GUI() Sleep(5) $aPosition = PixelSearch($Left, $Top, $Right, $Bottom, $Red, $RedColorSensitivity, 3) CheckTimer(@error) Until @error <> 1 If IsArray($aPosition) Then MouseMove($aPosition[0] + Random(-5, 5, 1), $aPosition[1] + Random(-3, 3, 1), 5) $SLeft = $aPosition[0] - 50 $SRight = $SLeft + 60 $STop = $aPosition[1] - 50 $SBottom = $STop + 65 EndIf Func CheckTimer($PixelError) If TimerDiff($Timer) >= $MaxTime Then SetError(0) Return -1 EndIf SetError($PixelError) EndFunc ;==>CheckTimer I dun understand =[[
monoscout999 Posted September 13, 2011 Posted September 13, 2011 Do $coord = PixelSearch(157, 98, 225, 146, 0x545453, 0, 1, "") $diff = TimerDiff($start) Until Not @error Or $diff > 10000 I am not sure about this... @error can be setted by the TimerDiff function so is useless, in this case you should use this Do $coord = PixelSearch(157, 98, 225, 146, 0x545453, 0, 1, "") $diff = TimerDiff($start) Until IsArray($coord) Or $diff > 10000
Blue_Drache Posted September 13, 2011 Posted September 13, 2011 (edited) I dun understand =[[ Then learn. The code I posted is from an operational program that I use at least once a week. It works exactly as advertised and does exactly what you're asking for. We're not here to write the bot* you want for you. We're not here to spoon feed you code. You can take what I posted apart line by line and learn what's going on, how the programming logic works, and cross reference it with the help file, or you can sit there and twiddle your thumbs and go nowhere. *Because that's what 99% of the pixelsearch questions boil down to. Game automation. Edited September 13, 2011 by Blue_Drache Dgameman1 1 Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Dgameman1 Posted September 13, 2011 Author Posted September 13, 2011 Then learn. The code I posted is from an operational program that I use at least once a week. It works exactly as advertised and does exactly what you're asking for. We're not here to write the bot* you want for you. We're not here to spoon feed you code. You can take what I posted apart line by line and learn what's going on, how the programming logic works, and cross reference it with the help file, or you can sit there and twiddle your thumbs and go nowhere. *Because that's what 99% of the pixelsearch questions boil down to. Game automation. Sorry about that, I didn't exactly look at it before, I kinda looked at it and said to myself womfg too much code.But now that I look at it, I just used the help file for stuff I didn't know. and it actually does exactly what I want it to do lolTHanks =P
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