Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#896 closed Feature Request (Rejected)

CPU intencive yet simple and powerful addition to PixelSearch

Reported by: ao0921@… Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


Would help greatly because algorithm is VERY CPU intensive and is effectively useless using UDF.

That could search the for a pixel that is the closes to a given $X and $Y input withing a square.
PixelSearchCloseBy ( x, y, squareSize, color, [, shade-variation [, step [, hwnd]]] )
Basically a search starting from he x and y and checking for similar colors around expanding pixel by pixel in square with a side = squareSize.

Here what I came up with to the best of what i know about C++:

int PixelSearchCloseBy(int x, int y, int squareSize, int color){

int out[2]={-1,-1};
int left, right, top, bottom, xx;
for(int i=1; i < squareSize/2; i++){

left = x-i;
right = x+i;
top = y-i;
bottom= y+i;
for(xx=left;xx<right;xx++){check top side of the squre

if(GetPixel(hdc,xx,top)){out[0]=xx;out[1]=top;return out;}

for(xx=top;xx<bottom;xx++){check right side

if(GetPixel(hdc,right,xx)){out[0]=right;out[1]=xx;return out;}

for(xx=right;xx<left;xx--){bottom side

if(GetPixel(hdc,xx,bottom)){out[0]=xx;out[1]=bottom;return out;}

for(xx=bottom;xx<top;xx--){left side

if(GetPixel(hdc,left,xx)){out[0]=left;out[1]=xx;return out;}




whatever you can do - appreciated

Attachments (0)

Change History (3)

comment:1 Changed 12 years ago by Valik

  • Resolution set to Rejected
  • Status changed from new to closed

Is there some reason you had to post this as a second ticket? Couldn't you have just posted the code as a new comment in #895?

Further, while the code is logically sound it uses GetPixel() rendering it useless. I would not be surprised at all if you (or at least somebody) can't write something in AutoIt faster than that. GetPixel() is horrible for repeated operations because it involves a tremendous amount of overhead per call.

Since you know C++ I suggest you write a DLL (optionally make it a plugin DLL). The API is undocumented but it is still there and people on the forum do know how to write plugins. You just need to start asking the right questions in the right place which is something you haven't done so far.

comment:2 follow-up: Changed 12 years ago by ao0921@…

sorry, I'm new to this, i was thinking i did something wrong to the first one. So i guess this function is more then AutoIt is planned to do? Also your name isn't that Russian? (just curious)

comment:3 in reply to: ↑ 2 Changed 12 years ago by Valik

Replying to ao0921@…:

sorry, I'm new to this, i was thinking i did something wrong to the first one.

In the future when you think you've done something wrong the first try ask how to do it right (on the forum) before trying again. As it is, you didn't do anything wrong the first time. You should have added your code as a new comment to the first ticket. Creating a new, identical (mostly) ticket was wrong.

So i guess this function is more then AutoIt is planned to do?

Yes. It offers only a slight variation over the standard PixelSearch().

Also your name isn't that Russian? (just curious)


Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.