Jump to content

Pixelsearch question


tiosha
 Share

Recommended Posts

Hi guys

I need to know how to make something like this:

Do
PixelSearch( X, Y, X, Y, color1 OR color2)
  Until not @error

Basically i want it to make a pixelsearch until it finds a pixel with color1 or 2

Any help? I've searched for this but i didnt found anything

Thanks in advanced

Link to comment
Share on other sites

This might help you.

#include <Misc.au3> ; For _IsPressed function.

Local $coord1, $coord2
Local $iColor1 = 0x000000 ; Black - RGB (Red, Green, Blue) colors in hex format 0xRRGGBB (example: Red is 0xFF0000)
Local $iColor2 = 0xFFFFFF ; White

Do
    If _IsPressed("1B") Then ExitLoop ; Press ESC to exit Do-Until loop

    $coord1 = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight, $iColor1) ; "-1" because my desktop has black where, 0 < X >= @DesktopWidth.
    If @error = 0 Then ExitLoop

    $coord2 = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight, $iColor2)
Until Not @error

If IsArray($coord1) Then
    MsgBox(0, "Results", "Color: 0x" & Hex($iColor1, 6) & " at " & $coord1[0] & "," & $coord1[1])
ElseIf IsArray($coord2) Then
    MsgBox(0, "Results", "Color: 0x" & Hex($iColor2, 6) & " at " & $coord2[0] & "," & $coord2[1])
Else
    MsgBox(0, "Results", "Cancelled", 2)
EndIf
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...