Relative vs. Absolute Cursor Position

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
pgriffin

Relative vs. Absolute Cursor Position

Post by pgriffin » Sat Feb 19, 2005 2:39 pm

I'd like to use GetPixelColor> with the cursor coordinates being Relative to the window instead of the absolute coordinates from the screen. My solution currently is to maximize the user's app to be sure I hit the same point with GetPixel.

Ideas?

thanks,

Paul

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sat Feb 19, 2005 6:36 pm

Hi,

Just get the X,Y coords of the window. Then add the relative position to these to get absolute X,Y coords and use these in GetPixelColor. E.g:


Let>relX=50
Let>relY=50
SetFocus>notepad*
GetActiveWindow>win,winX,winY
Let>absX=winX+relX
Let>absY=winY+relY
GetPixelColor>absX,absY,pcolor


This would get the pixel color of the pixel at position 50,50 relative to Notepad's top left corner.
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts