Image Meta Data
4.1.2 Image Meta Data
T-Plan Robot version 2.2 and higher save template images to the hard drive together with an additional text file containing image metadata such as the source coordinates and click point. Whenever the image is used for image comparison, the data is loaded and made available to the script in the form of predefined variables.
The metadata file is in the Java .properties format and its name is derived from the image file (typically <imagefile>.<formatextension>.properties). The GUI allows creating the metadata file for an already existing template created with the previous version or with a third party image editor. Since the source coordinates are however lost, the GUI, in this case, allows to edit and store only the click point.
Source coordinates store the original coordinates in the desktop image at the time of template creation. They are exposed to the script through the _COMPARETO_SOURCE_X and _COMPARETO_SOURCE_Y variables. These variables are not populated when the metadata file is not available or the data is not populated (templates created prior to v2.2 or with 3rd party tools).
Source coordinates allow scripting actions to test whether the object has moved on the screen. A typical piece of code for this action is:
Compareto "buttonOK" method=search
if (
"{_COMPARETO_SOURCE_X}" != "{_SEARCH_X}" && "{_COMPARETO_SOURCE_Y}" != "{_SEARCH_Y}
") {
# Object has moved
...
}
The Click Point represents the best location for an eventual mouse action such as a click, press, release or drag. The point defaults to the image centre but it can be customized to point to any location inside or even outside the template image rectangle. The click point coordinates are internally stored relatively to the template image top left corner.
Usage of the click point makes sense only with the image search. When it locates the object on the screen, it recalculates the click point to absolute coordinates and stores them under the _COMPARETO_CLICK_X and _COMPARETO_CLICK_Y variables. When the metadata file doesn't exist (templates created prior to v2.2), the variables are also available and default to the image centre. The following code snippet locates an object and on success clicks on its click point:
Compareto "buttonOK" method=search
if (
{_EXIT_CODE} == 0
) {
Mouse click to="x:{_COMPARETO_CLICK_X},y:{_
COMPARETO_CLICK
_Y}"
}