Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Getting co-ordinates for low-level events when testing Custom Controls

Getting co-ordinates for low-level events when testing Custom Controls

One of the most frustrating parts of creating tests that rely on low-level events is getting the co-ordinate offsets of the objects you want to interact with. The attached small program - getMousePos - should ease this frustration considerably by getting the offsets for you. There are two caveats with this:

1. If you are trying to get co-ordinates against the desktop to action objects in the application then either the application must be full-screen or alternatively, it can be relied upon to always appear in the same place and at the same size.

2. If you are trying to get offsets from objects within the application then the application must always appear as the same size. Placement on screen does not matter in this case. This setup is illustrated below.

Mouse Position uses the top left corner of the monitor as the absolute position to work from. If you want to get the rectangle co-ordinates of a object then proceed as follows:

1. Identify the top left corner of the child container and select ctrl+tab to freeze the display


2. Select 'Copy To Offsets' to transfer the co-ordinates to the X and Y offset boxes. The X Pos and Y Pos boxes will now use these co-ordinates as the starting point
3. Select 'Start Tracking' and move to the lower right corner of the object
4. Select ctrl+tab to freeze the display again


5. The display will now give you the x and y offset and the size of the rectangle required for the SilkTest RECT parameter
6. Select 'Show Rectangle' to get the absolute co-ordinate set.


Selecting 'Move to Pos' will move the mouse cursor to X Pos and Y Pos relative to any X Offset and Y Offset.


Required: dotNet Framework 4.0 or later.

This utility is provided 'as-is' and is not supported by Micro Focus.

getMousePos.zip

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-09-03 17:17
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.