Sign in to follow this  
Followers 0
Cotino

AutoitX PixelSearch acting weird

9 posts in this topic

#1 ·  Posted (edited)

Hi, first time posting here.

I'm trying to use PixelSearch into finding a moving pixel.  However, it can't even find a static pixel ...

If the rectangle is too wide, it doesn't find the pixel, however i tried with a 10*10 rectangle, and here it works.

I'm confused, is there a max size for the rectangle ? I'm looking for a 1280*800 rectangle.

Is there any other way i could do that ? I thought about doing a PixelGetColor over the whole screen, but that would take too much time. It has to search 5 times in 1sec.

Am i missing something ?

POINT pos = { 0, 0 };
RECT rect = { 0, 0, 1280, 800 };
int color = 0xFF00FF;

AU3_PixelSearch(&rect, color, 0, 1, &pos);
std::cout << pos.x << " " << pos.y;

Edit : Even weirder now, i search on a rectangle 1000,400,1100,500 and it finds a pixel on 447,403.

How is that even possible ? It shouldn't have checked that pixel at all.

Edited by Cotino

Share this post


Link to post
Share on other sites



On the header file.

AU3_API void WINAPI AU3_PixelSearch(LPRECT lpRect, int nCol, /*default 0*/int nVar, /*default 1*/int nStep, LPPOINT pPointResult);

Share this post


Link to post
Share on other sites

What do you mean, it's not supposed to be a rect ? It kinda works that way on very small rect.

Share this post


Link to post
Share on other sites

In help file it says (left, top, right, bottom, colour) 

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

value = oAutoIt.PixelSearch(0,0, 100, 100, 0)
If oAutoIt.error = 1 Then
  WScript.Echo "Color not found"
Else
  WScript.Echo "Color found at: " & value(0) & "," & value(1)
End If

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

I just figured it out.

Autoit reversed the left and right var of the rect. So, right is left, and left is right.

I wonder how it's possible that no one else made a thread about this. I can't be the only one to use pixelsearch, am i ?

Share this post


Link to post
Share on other sites

New problem now.

If i loop pixelsearch for a long time on a pixel, it will find that pixel at a certain position, usually max x and random y, and the only way to make it work again is to restart the computer. However, if i change the pixel, it works just fine.

Maybe it uses some kind of buffer that gets full if you use it too much, and using another pixel use another buffer ?

Share this post


Link to post
Share on other sites

I just figured it out.

Autoit reversed the left and right var of the rect. So, right is left, and left is right.

I wonder how it's possible that no one else made a thread about this. I can't be the only one to use pixelsearch, am i ?

I have noticed it in the past, and also figured the solution I'm sorry to admit, my memory is not what it used to be.

 

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

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