Hawkwing Posted September 14, 2009 Posted September 14, 2009 If you're using the script in #8 and the only thing changed was the hotkeys, then it's because the while loop goes while $bot = 1, and since $bot = 0 until you hit the hotkey, the while loop doesn't go. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
miketh2005 Posted September 14, 2009 Author Posted September 14, 2009 I'm using this: $bot = 0 ;Define bot HotKeySet("{PGUP}", "pageup") HotKeySet("{PGDN}", "pagedown") Func pageup() $Bot = 1 EndFunc Func pagedown() $Bot = 0 EndFunc While $bot = 1 ;a simple loop, that is always on when bot = 1 $coord = PixelSearch(0, 0, 4, 187, 0xB20000) If @error Then ;it's better to do, if it fails first $Start = TimerInit() ;a timer that starts when it doesn't count the pixel Else ;Else function, meaning if that doesn't happen, then do this MouseClick("left", $coord[0], $coord[1], 2) Sleep(5000) ;five seconds MouseClick("left", 1230, 167) EndIf If TimerDiff($Start) > 30000 Then ;when the timer is over 30 the script will exit Exit EndIf WEnd ;Ending the While loop
miketh2005 Posted September 14, 2009 Author Posted September 14, 2009 Ok... If I do this: HotKeySet("{PGUP}", "bot") $var = 0 While 1 = 1 Sleep(1000) WEnd Func bot() $coord = PixelSearch(0, 0, 4, 187, 0xB20000) If @error Then ;it's better to do, if it fails first Sleep(1000) $var = $var + 1 Else ;Else function, meaning if that doesn't happen, then do this MouseClick("left", $coord[0], $coord[1], 2) Sleep(5000) ;five seconds MouseClick("left", 1230, 167) bot() EndIf If $var = 30 Then ;when the timer is over 30 the script will exit Exit EndIf EndFunc ;==>bot Then it will end after I pressed PgeUp 30 times. If I do this one: HotKeySet("{PGUP}", "bot") $var = 0 While 1 = 1 Sleep(1000) WEnd Func bot() $coord = PixelSearch(0, 0, 4, 187, 0xB20000) If @error Then ;it's better to do, if it fails first Sleep(1000) $var = $var + 1 bot() Else ;Else function, meaning if that doesn't happen, then do this MouseClick("left", $coord[0], $coord[1], 2) Sleep(5000) ;five seconds MouseClick("left", 1230, 167) [b]bot()[/b] EndIf If $var = 30 Then ;when the timer is over 30 the script will exit Exit EndIf EndFunc ;==>bot It will just do nothing forever. So I guess it isn't finding the color or repeating the function "bot" when I call it. How do I get around this?
Hawkwing Posted September 14, 2009 Posted September 14, 2009 HotKeySet("{PGUP}", "setvar") HotKeySet("{PGDN}", "setvar") $bot = 0 While 1 = 1 Sleep(1000) If $bot = 1 Then bot() EndIf WEnd Func bot() While $bot = 1 ;a simple loop, that is always on when bot = 1 $coord = PixelSearch(0, 0, 4, 187, 0xB20000) If @error Then ;it's better to do, if it fails first $Start = TimerInit() ;a timer that starts when it doesn't count the pixel Else ;Else function, meaning if that doesn't happen, then do this MouseClick("left", $coord[0], $coord[1], 2) Sleep(5000) ;five seconds MouseClick("left", 1230, 167) EndIf If TimerDiff($Start) > 30000 Then ;when the timer is over 30 the script will exit Exit EndIf WEnd ;Ending the While loop EndFunc Func setvar() If $bot = 0 Then $bot = 1 Else $bot = 0 EndIf EndFunc The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
miketh2005 Posted September 14, 2009 Author Posted September 14, 2009 HotKeySet("{PGUP}", "setvar") HotKeySet("{PGDN}", "setvar") $bot = 0 While 1 = 1 Sleep(1000) If $bot = 1 Then bot() EndIf WEnd Func bot() While $bot = 1 ;a simple loop, that is always on when bot = 1 $coord = PixelSearch(0, 0, 4, 187, 0xB20000) If @error Then ;it's better to do, if it fails first $Start = TimerInit() ;a timer that starts when it doesn't count the pixel Else ;Else function, meaning if that doesn't happen, then do this MouseClick("left", $coord[0], $coord[1], 2) Sleep(5000) ;five seconds MouseClick("left", 1230, 167) EndIf If TimerDiff($Start) > 30000 Then ;when the timer is over 30 the script will exit Exit EndIf WEnd ;Ending the While loop EndFunc Func setvar() If $bot = 0 Then $bot = 1 Else $bot = 0 EndIf EndFunc SWWWWWWWWWWWWWEEEEEEEEEEEEEEEET!!!!!!!!!!! IT WORKS!1111!!!!!!!1!11!!!! e THATS SOOOOOOOO MUCH DUDE! Could you kindly explain what makes it work now, so I can learn from this experince? I'm sooooo very happy You made my day complete! I could hug you, lol!
Hawkwing Posted September 14, 2009 Posted September 14, 2009 "While $bot = 1" basically checks if $bot = 1, if it does, it loops until $bot <> 1. With your previous script, it set the hotkeys, then checked if $bot = 1 for the while loop. $bot <> 1 because you didn't have time to press pageup. Mine has a loop that goes no matter what, checking if $bot = 1. If $bot = 1 then it runs a func that goes until $bot <> 1. Actually there is an error in mine. You only need one hotkey. If you look at setvar() it just changes $bot from 0 to 1 or from 1 to 0 no matter what hotkey you press. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
miketh2005 Posted September 16, 2009 Author Posted September 16, 2009 (edited) I'm using this script: expandcollapse popupHotKeySet("{PGUP}", "setvar") HotKeySet("{PGDN}", "setvar") $bot = 0 While 1 = 1 Sleep(1000) If $bot = 1 Then bot() EndIf WEnd Func bot() While $bot = 1 ;a simple loop, that is always on when bot = 1 $coord = PixelSearch(0, 179, 1280, 816, 0xB20000) If @error Then ;it's better to do, if it fails first PixelSearch(0, 0, 1280, 1024, 0xD8FFD8) If @error Then ;it's better to do, if it fails first PixelSearch(0, 0, 1280, 1024, 0xFFD9D9) If @error Then ;it's better to do, if it fails first $Start = TimerInit() ;a timer that starts when it doesn't count the pixel Else Sleep(Random(2000, 8000, 1)) MouseClick("left", 815, 242) bot() EndIf Else Sleep(Random(2000, 8000, 1)) MouseClick("left", 596, 240) bot() EndIf Else ;Else function, meaning if that doesn't happen, then do this MouseClick("left", $coord[0], $coord[1], 2) Sleep(Random(5500, 10000, 1)) ;five seconds MouseClick("left", 1230, 167) bot() EndIf If TimerDiff($Start) > 30000 Then ;when the timer is over 30 the script will exit Exit EndIf WEnd ;Ending the While loop EndFunc ;==>bot Func setvar() If $bot = 0 Then $bot = 1 Else $bot = 0 EndIf EndFunc ;==>setvar When it gets to this part: MouseClick("left", $coord[0], $coord[1], 2) Sleep(Random(5500, 10000, 1)) ;five seconds MouseClick("left", 1230, 167) bot() Sometimes it just sits there and does nothing at all after it clicks. Like it sleeps forever instead of the specified amount of time. Seems like a bug with the AutoIT language? If I recall it wasn't doing that before I made it sleep randomly... I found that you can just say "ContinueLoop" instead of re-calling the bot() function. Maybe this might fix it? EDIT: I never even took out the pgedown hotkey, cause this is still in pre-alpha stage. I will when it makes it to beta. Edited September 16, 2009 by miketh2005
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