tykkimies Posted December 5, 2012 Share Posted December 5, 2012 (edited) First off i'll start by saying im very new to autoit and just trying to learn. I am playing around with the pixelsearch function, and decided to make a little bot for the flash game curveball, just for fun. I was able to make a basic one, but that required me to click the ball everytime. And i could add a mousclick in the loop and it would work, but i feel like thats not efficient. So i decided to try to make a cleaner looking code, and also teach myself about functions at the same time. Im attempting now to use the @error that comes along with pixelsearch to find when the color of the ball is not found. And then have that call a function to then research for the ball after a second or 2 and click and then start bot again. My code looks like this, and please be nice if ive done something stupid. Which im sure i have. HotKeySet("{a}", "_StartBot") HotKeySet("{p}", "_PauseBot") HotKeySet("{q}", "_ExitBot") While 1 Sleep(100) WEnd Func _StartBot() $Active = _BotRun(1) EndFunc Func _BotRun($Active) While $Active = 1 $Ball = PixelSearch(536, 210, 1013, 528,0xDFFFD7) if @error = 1 Then _newBall() ElseIf IsArray($Ball) Then MouseMove($Ball[0], $Ball[1 ], 0) EndIf WEnd EndFunc Func _newBall() sleep(1000) $Ball = PixelSearch(536, 210, 1013, 528,0xDFFFD7) If IsArray($Ball) Then MouseMove($Ball[0], $Ball[1], 0) sleep(1000) MouseClick("Left") _BotRun(1) EndIf EndFunc Func _PauseBot() _BotRun(0) EndFunc Func _ExitBot() Exit EndFunc So my problem in this is that the mouse movements only happen every few seconds rather than tracking like it did with just pixelsearch. Is this just too much searching around for autoit? or is there a better way to do this? Edited December 5, 2012 by tykkimies Link to comment Share on other sites More sharing options...
water Posted December 5, 2012 Share Posted December 5, 2012 Welcome to AutoIt and the forum!Please have a look at the forum rules and you will see why you won't get any help with your script. Game automation isn't permitted here.Hope to see you with a legitimate question soon. 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