Sign in to follow this  
Followers 0
BlueC

Pixelsearch Problem

5 posts in this topic

Hello.

I'm attempting to make a macro that starts after detecting a red pixel in a specific area of a window. It's a simple check as follows...

While 1
    (etc...)
    $Search = Pixelsearch($X+50, $Y+50, $X+250, $Y+300, 0xFF0000)
    If $Search >= 1 Then
        (etc...)
    EndIf
    Sleep(10000)
WEnd

The rest of the code has been tested without a Pixelsearch and works fine, but the problem is the Pixelsearch only works for 2 out of 6 people, not including myself.

I tried verifying the color being searched for by using a Color Test.au3 that was posted elsewhere, but the Pixelsearch still failed with the new color code.

Then I tried changing the tolerance to 30, 50, and finally 255, and the Pixelsearch still did not succeed.

I can't tell what the problem is since the program works as intended for two people, but not the rest. Any ideas?

Share this post


Link to post
Share on other sites



I'm unsure if its safe to test an array against an int.

You should test PixelSearch like

While 1
    (etc...)
    $Search = Pixelsearch($X+50, $Y+50, $X+250, $Y+300, 0xFF0000)
    If Not @error Then
        (etc...)
    EndIf
    Sleep(10000)
WEnd

Or maybe

While 1
    (etc...)
    $Search = Pixelsearch($X+50, $Y+50, $X+250, $Y+300, 0xFF0000)
    If IsArray($Search) Then
        (etc...)
    EndIf
    Sleep(10000)
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Look at the help file, it has the return type of every function... i told you that because maybe the func doesn`t return a value >= 1 , You have to check in the help file the return type of the functions

Share this post


Link to post
Share on other sites

You should test PixelSearch like

While 1
    (etc...)
    $Search = Pixelsearch($X+50, $Y+50, $X+250, $Y+300, 0xFF0000)
    If Not @error Then
        (etc...)
    EndIf
    Sleep(10000)
WEnd

This one worked wonders for me, thanks. Hopefully it solves the others' problem too.

Look at the help file, it has the return type of every function... i told you that because maybe the func doesn`t return a value >= 1 , You have to check in the help file the return type of the functions

Hm, it says it returns the pixel's coordinates, wouldn't that always be an integer greater than 1?

I thought since it was working for 2 of the people that that was the case and there was just something wrong with my colors or hardware.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The return data is the pixel coordinates... the return type is an Array

$aArray = pixelsearch(0, 0, 1, 1, 0xFFFFFF,255);search any color
If NOT @error then
consolewrite($aArray&@CRLF) ;will not work
consolewrite("X pos "&$aArray[0]&" Y pos "&$aArray[1]&@CRLF) ; this will return "X pos 0 Y pos 0"
Endif

Try comment out one consolewrite and uncomment the another...

Edited by monoscout999

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  
Followers 0