Jump to content

PixelSearch Help Please


Recommended Posts

I want this program to find a certain color, and keep clicking it until it goes away.

I'm not good with pixel stuff please help.

Search()

Func Search()
    Sleep(10)


$Place = PixelSearch ( 0, 0, @DesktopWidth, @DesktopHeight, 779296, 10 )
    Sleep(10)

If @error Then
    Sleep(10)
    Search()
Else

MouseClick ( "left", $Place[0], $Place[1], 2 , 5 )
    Sleep(10)
EndIf
Endfunc

Error: Subscript used with non-Array variable.

-Brett
Link to comment
Share on other sites

  • Developers

think you made possible logic error here.

Search is calling itself repeatedly in case of errors ... and i don't think you want to do that recursion stuff.

you could do it this way:

Func Search()
   $PLACE = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 779296, 10)
   While @error
      Sleep(10)
      $PLACE = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 779296, 10)
   Wend
   MouseClick("left", $PLACE[0], $PLACE[1], 2, 5)
EndFunc  ;==>Search

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...