Jump to content

PixelSearch


Info
 Share

Recommended Posts

HotKeySet ( "{F6}", "XD")
Func XD()
If PixelSearch ( 0, 0, 1000, 1000, 0xF16814) = True Then
    MsgBox ( 0, "Yay", "GOT IT!")
EndIf
If PixelSearch ( 0, 0, 1000, 1000, 0xF16814) = False Then
    MsgBox ( 0, "NOT", "Can't find")
EndIf
EndFunc

While 1
Sleep (100)
WEnd

Even if I got my whole screen in black, it still says that there is the color 0xF16814 (orange)

The "0, 0, 1000, 1000" marks the whole screen.

Help please...

Edited by Info
Link to comment
Share on other sites

HotKeySet ( "{F6}", "XD")
Func XD()
If PixelSearch ( 0, 0, 1000, 1000, 0xF16814) = True Then
    MsgBox ( 0, "Yay", "GOT IT!")
EndIf
If PixelSearch ( 0, 0, 1000, 1000, 0xF16814) = False Then
    MsgBox ( 0, "NOT", "Can't find")
EndIf
EndFunc

While 1
Sleep (100)
WEnd

Even if I got my whole screen in black, it still says that there is the color 0xF16814 (orange)

The "0, 0, 1000, 1000" marks the whole screen.

Help please...

If PixelSearch() finds the pixel it returns an array containing the coords. If it fails to find the pixel it returns 1 and sets @error to 1. To fix your code you need to check the value of @error rather than treating the return from PixelSearch() as a boolean.

Somthing like this works

HotKeySet ( "{F6}", "XD")
Func XD()
Local $pixel

    $pixel = PixelSearch ( 0, 0, 1000, 1000, 0xF16814)
    If @error Then
        MsgBox ( 0, "NOT", "Can't find")
    Else
        MsgBox ( 0, "Yay", "GOT IT! at " & $pixel[0] & "," & $pixel[1])
    EndIf
EndFunc

While 1
Sleep (100)
WEnd

Edit: Fixed coords in second MsgBox

Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

OMG THANKS ^^

There's still a problem, I don't know how to make it wait until the "PixelSearch ( 0, 0, 1000, 1000, 0xXXXXXX)" appears...

Help?

I'm not sure if this is what you are trying to do.

This will keep searching For your pixel Until it is found.

If it is Not found within 3 minuets (180000 milli seconds) the function will display Not found

If it is found the function will display coords of pixel

HotKeySet ( "{F6}", "XD")
Func XD()
Local $pixel = 0
Local $Timer = TimerInit()
    While TimerDiff($Timer) < 180000 ; Search for pixel for 3 minuets
        $pixel = PixelSearch ( 0, 0, 1000, 1000, 0xF16814)
        If Not @error Then 
            MsgBox ( 0, "Yay", "GOT IT! at " & $pixel[0] & "," & $pixel[1])
            Return
        EndIf
        Sleep(250)
    WEnd
    MsgBox ( 0, "NOT", "Can't find")
EndFunc

While 1
Sleep (100)
WEnd

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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