cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with "Get Bounds" in Surface Automation

Anonymous
Not applicable
Hi, When trying to work with Surface Automation with different types of applications, sometimes an issue appears when using "Get Bounds" and subsequently "Read Image". The issue is that sometimes after reading the bounds of e.g. a window and using these for capturing an image, the image gets skewed. The result is a screenshot somewhere on the screen with the same proportions as the window, but not containing the window. For some reason it seems to work if we place the window in the top left corner of the screen, but not if it is placed anywhere else. So my questions are: 1. Have anyone else experienced these issues and know how to solve it? 2. What is the difference between "Get Bounds" and "Get Screen Bounds" and what contexts are they designed for? Any input is much appreciated. BR, Sebastian
4 REPLIES 4

John__Carter
Staff
Staff
Hi Sebastian - Get Bounds gives you the position of a region in relation to it's parent element. It's important to realise that a region is a child of the element you CTRL clicked to enter the Region Mode Editor screen, and if the parent element moves, then so will the region. One way to combat this is to make sure the parent of the region is something with a fixed location relative to the window. Often the easiest way to do this is to choose the window itself as the region parent, so you always know where the origin is. With Screen Bounds the origin is the top left of the desktop.

Anonymous
Not applicable
Hi John, I really appreciate the quick answer. I understand what you are saying, but I have some follow-up questions: In this case, the window of which we wish to get the bounds is the main application window itself. Thus, what would then be considered to be the ""parent of the parent""? I would have assumed this to be the entire desktop, but as said, we have experienced some issues when getting those bounds and then reading an image based on them. Based on the logic you present above, I take it as ""Get Screen Bounds"" would have rendered a good screenshot as we then would have based the coorindates off of the entire desktop? However, we tried this as well without succeeding. Or am I to understand that whatever coorindates I get from the ""Get Bounds"" / ""Get Screen Bounds"", the ""Read Image"" starts looking from the top left of the Dynamic Region's parent rather than from the entire desktop window? Sorry for the confusion - we just really want to understand this properly. Thanks, Sebastian

John__Carter
Staff
Staff
Hi Sebastian - with Get Bounds 0,0 is in the top left of the parent element. So if the region 'belongs' to the main window, the origin is the top left corner. With Get Screen Bounds 0,0 is the top left of the desktop.

Anonymous
Not applicable
Thanks John! Now I have a better understanding and think I can troubleshoot confidently. BR, Sebastian