Jump to content

Using Two Pixel Search


jimmer
 Share

Recommended Posts

$coord = PixelSearch(566,261,566,261,0x000000) & $coord = PixelSearch(566,281,566,281,0x000000)
if @error then 
MouseClick("Left", 630, 308, 1, 0)
Sleep(600)
endif 
if not @error then
sleep(1000)
endif

Alright, I would just like the first coord to work together with the second... but this code just doesn't seem to do the job?

I would like both coords to work together, but I guess the "&" just won't cut it

It's searching for two different pixel, (566 261) and (566 281), not (566, 261, 566, 281)

so yeah.... hope you can understand my bad grammar

Link to comment
Share on other sites

Alright, I would just like the first coord to work together with the second... but this code just doesn't seem to do the job?

I would like both coords to work together, but I guess the "&" just won't cut it

It's searching for two different pixel, (566 261) and (566 281), not (566, 261, 566, 281)

The "&" is used to concatenate strings. The "And" operator is used to do multiple conditions in one statement. What you need is to do two separate searches, and test each result afterwards. Here are two examples. I used "Else" instead of two "If" statements.

$color1 = 0x000000

; Example 1
$coord1 = PixelSearch(566, 261, 566, 261, $color1)
If @error Then
   $coord2 = PixelSearch(566, 281, 566, 281, $color1)
   If @error Then
      MsgBox(4096, 1, "Color not found at either location.")
      MouseClick("Left", 630, 308, 1, 0)
      Sleep(600)
   Else
      MsgBox(4096, 2, "Color found at 2nd location only.")
      Sleep(1000)
   EndIf
Else
    MsgBox(4096, 3, "Color found at 1st location (did not check 2nd location).")
   Sleep(1000)
EndIf


; Example 2
IsArray($coord1)
$coord1 = PixelSearch(566, 261, 566, 261, $color1)
$coord2 = PixelSearch(566, 281, 566, 281, $color1)
If Not IsArray($coord1) And Not IsArray($coord2) Then
   MsgBox(4096, 11, "Color not found at either location.")
   MouseClick("Left", 630, 308, 1, 0)
   Sleep(600)
Else
   MsgBox(4096, 22, "Color found at at least one location.")
   Sleep(1000)
EndIf

Exit

Phillip

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