Vexhero Posted April 24, 2016 Share Posted April 24, 2016 Hello! So I am new to Autoit but I understand the syntax a bit (Coming from C#) And I created this function but for some reason it only clicks once (does the function one time) then it stops, why is that? expandcollapse popupHotKeySet("{ESC}", "myExit") Global $needrest = False; While 1 checkHealth() WEnd Func LC($x, $y) MouseClick("left", $x, $y, 1, 1) EndFunc Func ViewReset() MouseClick("left",551, 55,1,1) Send("{UP down}") EndFunc Func checkHealth() $needrest = True $hpBar = PixelSearch(724, 58, 726, 61, 0x8A0502, 1) ;MsgBox(0,"test", "Your health is full") if @error Then $findFood = PixelSearch(556, 240, 738, 493,0xE44C1B,5) If NOT(@error) Then LC($findFood[0],$findFood[1]) ;this is the thing it only does once I want the checkHealth() function to loop EndIf While($needrest) WEnd EndIf EndFunc Func myExit() MsgBox(0, "Exiting", "The Bot Has Quit") Exit EndFunc Link to comment Share on other sites More sharing options...
Trong Posted April 24, 2016 Share Posted April 24, 2016 HotKeySet("{ESC}", "myExit") Global $needrest = False; While 1 checkHealth() WEnd Func LC($x, $y) MouseClick("left", $x, $y, 1, 1) EndFunc ;==>LC Func ViewReset() MouseClick("left", 551, 55, 1, 1) Send("{UP down}") EndFunc ;==>ViewReset Func checkHealth() $needrest = True Local $hpBar = PixelSearch(724, 58, 726, 61, 0x8A0502, 1) ;MsgBox(0,"test", "Your health is full") If @error Then Local $findFood = PixelSearch(556, 240, 738, 493, 0xE44C1B, 5) If Not (@error) Then LC($findFood[0], $findFood[1]) ;this is the thing it only does once I want the checkHealth() function to loop EndIf ;~ While ($needrest) ;~ WEnd EndIf EndFunc ;==>checkHealth Func myExit() MsgBox(0, "Exiting", "The Bot Has Quit") Exit EndFunc ;==>myExit Maybe here: While ($needrest) WEnd Regards, Link to comment Share on other sites More sharing options...
Vexhero Posted April 24, 2016 Author Share Posted April 24, 2016 5 minutes ago, VIP said: HotKeySet("{ESC}", "myExit") Global $needrest = False; While 1 checkHealth() WEnd Func LC($x, $y) MouseClick("left", $x, $y, 1, 1) EndFunc ;==>LC Func ViewReset() MouseClick("left", 551, 55, 1, 1) Send("{UP down}") EndFunc ;==>ViewReset Func checkHealth() $needrest = True Local $hpBar = PixelSearch(724, 58, 726, 61, 0x8A0502, 1) ;MsgBox(0,"test", "Your health is full") If @error Then Local $findFood = PixelSearch(556, 240, 738, 493, 0xE44C1B, 5) If Not (@error) Then LC($findFood[0], $findFood[1]) ;this is the thing it only does once I want the checkHealth() function to loop EndIf ;~ While ($needrest) ;~ WEnd EndIf EndFunc ;==>checkHealth Func myExit() MsgBox(0, "Exiting", "The Bot Has Quit") Exit EndFunc ;==>myExit Maybe here: While ($needrest) WEnd That worked! But now it spam clicks the leftclick here $findFood = PixelSearch(556, 240, 738, 493,0xE44C1B,5) If NOT(@error) Then LC($findFood[0],$findFood[1]) EndIf Is there a way to change this so it only clicks once? Link to comment Share on other sites More sharing options...
Trong Posted April 24, 2016 Share Posted April 24, 2016 (edited) Maybe: -snip- Edited April 24, 2016 by Jos You should know better too! Regards, Link to comment Share on other sites More sharing options...
Developers Jos Posted April 24, 2016 Developers Share Posted April 24, 2016 @Vexhero, Seems you are automating a game when reading through your posted script comments, as that contains terms that will not be used on any regular program. So please ensure you read our Forum rules first before making a next post! Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts