About8Bobcats Posted June 9, 2017 Share Posted June 9, 2017 So I can't get this to loop properly. I've tried while loops but the problem with that is once it figures out what if statement to use it will loop that same one endlessly. The script works fine when I manually loop it (F5) -- Any ideas? This is only my second day into this language :\ HotKeySet("{F1}","myExit") Global $var1 = Hex(PixelGetColor(1412, 95), 6) Global $var2 = Hex(PixelGetColor(1499, 124), 6) ;Check if var1 is blue and var2 is green if $var1 = "1A2134" And $var2 = "373317" Then MsgBox("","","Success",1) MouseMove(1313,72) MouseClick("Left") MouseMove(1456,77) Sleep(500) EndIf ;Check if var1 is green and var2 is blue if $var1 = "3D3113" And $var2 = "172336" Then MsgBox("","","Success",1) MouseMove(1313,72) MouseClick("Right") Sleep(500) MouseClick("Left") MouseMove(1456,77) Sleep(500) EndIf Func myExit() MsgBox(0, "Attention", "Your bot has been terminated.") Exit EndFunc Link to comment Share on other sites More sharing options...
water Posted June 9, 2017 Share Posted June 9, 2017 Welcome to AutoIt and the forum! Can you please tell us which program you try to automate? Pixel functions and MouseMove to fixed coordinates is not very reliable as it depends on screen resolution and and window postion. There are - most of the time - more reliable ways to do what you want to do. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
About8Bobcats Posted June 9, 2017 Author Share Posted June 9, 2017 40 minutes ago, water said: Welcome to AutoIt and the forum! Can you please tell us which program you try to automate? Pixel functions and MouseMove to fixed coordinates is not very reliable as it depends on screen resolution and and window postion. There are - most of the time - more reliable ways to do what you want to do. Thanks. It's for a game however nothing is moving in the game until the mouse is clicked. getting pixel information is something that must be done because there's different colours in a static area after each mouse click. My screen resolution and position is always the same so that should be good. I know I probably could have put each if statement into an array or function but that's a little too complex for me at the time. I'm not quite sure if you understood completely what I mean't but this is what I did before; HotKeySet("{F1}","myExit") Global $var1 = Hex(PixelGetColor(1412, 95), 6) Global $var2 = Hex(PixelGetColor(1499, 124), 6) While 1 ;Check if var1 is blue and var2 is green if $var1 = "1A2134" And $var2 = "373317" Then MsgBox("","","Success",1) MouseMove(1313,72) MouseClick("Left") MouseMove(1456,77) Sleep(500) EndIf ;Check if var1 is green and var2 is blue if $var1 = "3D3113" And $var2 = "172336" Then MsgBox("","","Success",1) MouseMove(1313,72) MouseClick("Right") Sleep(500) MouseClick("Left") MouseMove(1456,77) Sleep(500) EndIf Wend Func myExit() MsgBox(0, "Attention", "Your bot has been terminated.") Exit EndFunc But the while would loop the same mouse movement Link to comment Share on other sites More sharing options...
water Posted June 9, 2017 Share Posted June 9, 2017 Seems you missed to read the forum rules on your way in. Please do so no. Especially the part about game automation. This isn't allowed here. Hence you won't get any help on this subject. Hope to see you soon with a legitimate question My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts