Jump to content

Recommended Posts

Posted

While(1)

   buybutton (864, 622)

WEnd

Func buybutton ($x, $y)
   $target = PixelSearch($x -5, $y -300, $x +5, $y +300, 0xFFEE8C,5)
   If not (@error) Then
      sleep (100)
      Mouseclick("left",$target[0], $target[1], 1, 1)
      $purple = PixelSearch(894, 589, 895, 590, 0xFFC8C8,5)
      If $purple=not @error Then
         Mouseclick("left",894, 589, 1, 1)
      sleep (5000)

        EndIf
      EndIf
EndFunc

 

 

I'm trying to make a program where it commences a pixelsearch, and after it clicks the button, it pixelsearches again for another button that will appear. However my program is ignoring the pixelsearch - it's executing the second mouseclick before the second button even shows. 

 

What am I doing wrong?

Posted

I've found the problem sort of... It's that the second button took a while to load, and so the program couldnt find it and just ended the script.

 

How do I make the program wait until the button appears

Posted
10 hours ago, DragonFroot said:

How do I make the program wait until the button appears

$Count = 0
While True
  $ret = pixelsearch (....)
  if not @error then exitloop ; found so leave the loop
  $Count += 1
  if $Count > 100 then return ; if not found after 10 secs leave the function
  sleep (100)
Wend

; $ret contains the x,y position

 

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