how to convert windows screen coordinates to screenshot pixel coordinates?
I need to find a control on screenshot. I have its screen coordinates. How can I convert them to coordina开发者_如何学Ctes on screenshot?
It all depends on the size of the screenshot and the size of your current resolution.
Let's say the screenshot is 800x600, but your current screen resolution is 1280x720. In order to find out the X,Y position on a 800x600 image, you need to normalize the values you have of X,Y on a 1280x720 screen.
normalized_x = (x * 800) / 1280;
normalized_y = (y * 600) / 720;
Note that the object you are looking for is also smaller on a 800x600 image. So:
// w and h represents the size of the object at 1280x720
normalized_w = (w * 800) / 1280;
normalized_h = (h * 600) / 720;
精彩评论