Jump to content
Sign in to follow this  
mcfreal

Pixelsearch Loop Help

Recommended Posts

mcfreal

I need for it to find the grey (#555555) pixel in the box at 106 left 89 top.

Then repeatedly press 2 (waiting 300 ms in between each), until it finds the

blue (#04ACEB).

I don't believe "Until $color=PixelSearch(203,82,206,100,0x04ACEB) not @error"

(Until it finds the blue in the box). is valid but I'm new to this.

Any ideas on how I can fix it?

While True
   If $use = 1 Then
      $size = WinGetClientSize("RagII", "")
      $color=PixelSearch(106,82,109,100,0x555555)
      ; If PixelSearch finds the pixel color at given coordinates, Then:
      If Not @error Then
          Do
                  Send(2)
                  Sleep(300)
          Until $color=PixelSearch(203,82,206,100,0x04ACEB) not @error        
      EndIf
   EndIf
WEnd

Share this post


Link to post
Share on other sites
Zedna

Probably something like this

While True
   If $use = 1 Then
      $size = WinGetClientSize("RagII", "")
      $color=PixelSearch(106,82,109,100,0x555555)
      ; If PixelSearch finds the pixel color at given coordinates, Then:
      If Not @error Then
          While 1
        $color=PixelSearch(203,82,206,100,0x04ACEB) 
        If @error Then ExitLoop
            Send(2)
            Sleep(300)
          WEnd
      EndIf
   EndIf
WEnd

Share this post


Link to post
Share on other sites
mcfreal

Probably something like this

While True
   If $use = 1 Then
      $size = WinGetClientSize("RagII", "")
      $color=PixelSearch(106,82,109,100,0x555555)
      ; If PixelSearch finds the pixel color at given coordinates, Then:
      If Not @error Then
          While 1
        $color=PixelSearch(203,82,206,100,0x04ACEB) 
        If @error Then ExitLoop
            Send(2)
            Sleep(300)
          WEnd
      EndIf
   EndIf
WEnd

So would "If @error Then ExitLoop" actually cease the looping

or just start the loop from the beginning?

I need it to keep pressing 2 over and over until it finds that

0x04ACEB pixel, then go all the way back to the beginning of the script,

not just the loop.

Still not working.

Most recent revision:

While 1
    Do
    $color=PixelSearch(106,82,109,100,0x555555)
    Until Not @error
          While 1
            $color=PixelSearch(203,82,206,100,0x04ACEB) 
            If @error Then ExitLoop
            Send(2)
          WEnd
WEnd
Edited by mcfreal

Share this post


Link to post
Share on other sites
Zedna

So would "If @error Then ExitLoop" actually cease the looping

or just start the loop from the beginning?

I need it to keep pressing 2 over and over until it finds that

0x04ACEB pixel, then go all the way back to the beginning of the script,

not just the loop.

Still not working.

Most recent revision:

What about this?

While True
   If $use = 1 Then
      $size = WinGetClientSize("RagII", "")
      $color=PixelSearch(106,82,109,100,0x555555)
      ; If PixelSearch finds the pixel color at given coordinates, Then:
      If Not @error Then
          While 1
        $color=PixelSearch(203,82,206,100,0x04ACEB) 
        If Not @error Then ExitLoop
            Send(2)
            Sleep(300)
          WEnd
      EndIf
   EndIf
WEnd

Share this post


Link to post
Share on other sites
mcfreal

I'm about to give it a shot, bump

Share this post


Link to post
Share on other sites
mcfreal

Success! <3s Zedna

While 1
    Do
    $color=PixelSearch(106,82,109,100,0x555555)
    Until Not @error
          While 1
            $color=PixelSearch(203,82,206,100,0x04ACEB) 
            If not @error Then ExitLoop
            Send(2)
          WEnd
WEnd
Edited by mcfreal

Share this post


Link to post
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
Sign in to follow this  

×