AutoHotkey Community

It is currently May 27th, 2012, 11:51 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Reverse Pixel Search
PostPosted: August 26th, 2010, 11:42 pm 
Offline

Joined: November 22nd, 2008, 9:52 pm
Posts: 44
Code:
PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID [, Variation, Fast|RGB]

x1, y1 - The X and Y coordinates of the upper left corner of the rectangle to search, which can be expressions. Coordinates are relative to the active window unless CoordMode was used to change that.

x2, y2 - The X and Y coordinates of the lower right corner of the rectangle to search, which can be expressions. Coordinates are relative to the active window unless CoordMode was used to change that.


Is there a way to reverse it, instead of searching from the top left, to search from the bottom right ? (I tried with switching the numbers, but it doesnt find anything if X2 > X1)

(I need the mouse to move to the bottom/left instead of the top left corner .. and since the search starts from there ..)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Reverse Pixel Search
PostPosted: August 27th, 2010, 12:22 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
me10c wrote:
I need the mouse to move to the bottom left instead of the top left corner

Is this height/difference a known value?
You could simply move the mouse before performing anything desired (a click, perhaps) if the pixel is found.

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2010, 12:27 am 
Offline

Joined: November 22nd, 2008, 9:52 pm
Posts: 44
I need the script to find a black square (for example) and mousemove at the bottom-right, not the top-left.

ex.

Code:
PixelSearch, SomeX, SomeY,300, 300, 100, 100, 0x000000, 0, Fast
Mousemove, SomeX, SomeY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2010, 12:32 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Although it may affect performance, you may try this:
Code:
DesiredColor := 0 ; black is zero

; be sure to invert those coordinates (use normally)
PixelSearch, CurrentX, CurrentY,100, 100, 300, 300, %DesiredColor%, 0, Fast

If ErrorLevel
  Return ; do not proceed if not successful

CurrentColor := DesiredColor ; make them the same
While ( CurrentColor = DesiredColor ) ; while they're the same...
  PixelGetColor, CurrentColor, CurrentX, ++CurrentY ; ...get the color of the next pixel (going down)

MouseMove, CurrentX, --CurrentY ; correct the Y position and move mouse
MsgBox, Mouse should now be at [%CurrentX%,%CurrentY%]

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Last edited by MasterFocus on August 27th, 2010, 12:37 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2010, 12:36 am 
Offline

Joined: November 22nd, 2008, 9:52 pm
Posts: 44
It works a bit slower (I assume this is due to my slow-ish CPU) but it does the job. Thanks :).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2010, 5:47 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
me10c wrote:
I need the script to find a black square (for example) and mousemove at the bottom-right, not the top-left.

ex.

Code:
PixelSearch, SomeX, SomeY,300, 300, 100, 100, 0x000000, 0, Fast
Mousemove, SomeX, SomeY


Did you guys miss the fine print :wink:
http://www.autohotkey.com/docs/commands/PixelSearch.htm
Slow mode only
The default left-to-right search order can be inverted by swapping X1 and X2 in the parameter list.
In other words, if X1 is greater than X2, the search will be conducted from right to left, starting at column X1.
Similarly, if Y1 is greater than Y2, each column of pixels to be searched starting at the bottom rather than the top.

Finally, if the region to be searched is large and the search is repeated with high frequency, it may consume a lot of CPU time.
To alleviate this, keep the size of the area to a minimum.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2010, 6:42 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Probably the first time I miss something quite like that! Thanks Leef_me!

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, MSN [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group