Sign in to follow this  
Followers 0
tykkimies

Need help with a simple script

2 posts in this topic

#1 ·  Posted (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 by tykkimies

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0