Jump to content

Recommended Posts

Posted

HotKeySet("{f8}", "shoot")
HotKeySet("{f9}", "pause")

$left = 130
$top = 150
$right = 640
$bottom = 490

$color = "0xFFFFFF"

pause()

func shoot()

While 1
If Not @error Then
$coords = PixelSearch ($left, $top, $right, $bottom, $color, 30)
MouseClick ("left",$coords[0], $coords[1])
endif
WEnd
endfunc

func pause()
While 1
Sleep(10)
WEnd
endfunc

While 1
Sleep(10)
WEnd

i cant figure it out, it works fine if the color is found, but if not it errors, anyway to say that if it doesnt find the color to just sleep?

  • Developers
Posted

Func shoot()
    While 1
        $coords = PixelSearch($left, $top, $right, $bottom, $color, 30)
        if @error Then
        ; notfound
        Else
            MouseClick("left", $coords[0], $coords[1])
        EndIf
    WEnd
EndFunc  ;==>shoot

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.
  :)

Posted

While 1
If Not @error Then
$coords = PixelSearch ($left, $top, $right, $bottom, $color, 30)
MouseClick ("left",$coords[0], $coords[1])
endif
WEnd

i cant figure it out, it works fine if the color is found, but if not it errors, anyway to say that if it doesnt find the color to just sleep?

<{POST_SNAPBACK}>

The @error macro is set to 1 when PixelSearch does not find a match. So test for it after the PixelSearch, lik this:

While 1
  $coords = PixelSearch ($left, $top, $right, $bottom, $color, 30)
  If Not @error Then
    MouseClick ("left",$coords[0], $coords[1])
  endif
WEnd

Phillip

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...