Using Images


Images are very useful in vTask, as they allow you to match exactly and interact with what is seen on the screen. Knowing how to create and access images is critical to using them successfully in vTask.


Creating Images for use in vTask
 

There are various ways to create images for use in vTask:
The best image format is the Windows Bitmap (BMP). vTask can handle other image formats, such as JPEG and GIF, but they are lossy formats, meaning the image representation may not match the screen image exactly. The maximum size for an image comparison is 1600 x 1600 pixels, however it is strongly recommended to use images as small as possible.


Using Images in vTask
 

Once you have an image, you can use it for many vTask actions. Common uses are moving the mouse to an image, and for window identification. If you use an image of a window, the image matching will not work if the window becomes "disabled", because the on-screen representation of the window will be dimmed.


*Tip:  The image must be visible on the screen for image identification to work. If the image is covered by another window, the image will not be found.


There are many options available for locating screen images. The Properties window provides the following settings:




Using Image Masks
 

"Masking" an image refers to ignoring part of an image, so that it is not used for the bitmap comparison. This is useful for inner portions of an image that may change, and you do not want to be used for matching. For the current version of vTask, the mask area is represented by the color pink (#FF00FF).

For example, using the Calculator program, the following image would only match the "5" button:



However, the following masked image would match any of the number buttons:



Another example would be to mask out a portion of an entry field, so the field is found no matter what the user types in the field.

*Tip:  vTask utilizes many internal optimizations for bitmap searching, however large bitmaps, especially with masking, can be slow on large screens. To increase the efficiency of bitmap searches, be sure to use the smallest bitmap image possible to find what you are looking for.



Sample of Web Image Interaction
 

As mentioned in the Identifying Windows and Controls page, web-based programs do not behave as standard Windows controls and windows. To work with internet controls, image-based scripts work the best. The key to working with web images is being able to identify the smallest portion of the web page that can be used for identification.

Many times, you will need to mask out portions of the image that might change. In the example below, the email login page can be easily identified by the small second image, however it may be necessary to mask out the User Name field. This will allow the image identification to work even if another user's name appears in the edit control.



Recommended identifying image:





Matching ClearType Text
 

*Tip:  Be aware that some image manipulation programs will perform functions with "anti-aliasing". This is a pixel-softening technique which changes the actual color components of pixels on the edge of selections and drawings. Paint Shop Pro and Adobe Photoshop are examples of programs that do this. With an anti-aliased edge, a perfect pixel-by-pixel comparison can be done with vTask, but the "Pixel Tolerance" must be adjusted. Be sure to disable anti-aliasing when creating images to use in vTask.


Windows XP and greater includes a screen display option called "ClearType" that smooths the edges of fonts.



This feature causes individual pixels to change their color to provide a smoother image for font curves. This results in text that is easier to read, however it causes problems with image matching.

       


The best option for obtaining consistent image matching is to have a source image that matches the screen resolution (use ClearType when creating the source image). If this is not possible, the following approach may help find images when the ClearType setting is unknown:

  100 - ( ( [total image pixel count] / [number of characters * 20] ) * 100 )  

This formula tries to calculate the number of extra pixels that ClearType adds or changes, based on the number of characters in your search text. This basic strategy ignores font size, which is can significantly change the values. By viewing the "5" button sample above, you can see that approximately 20 pixels have changed. In a character like "L", almost no pixels will change, however "O" may have many pixels changed. The above formula is an informal calculation based on image match testing.

*Tip:  The best approach is to use a source image that matches your screen settings. If that's not possible, an easier formula for matching ClearType text is to start with Tolerance=32 and Required %=95, and then gradually increase the Tolerance and lower the Required % value until you achieve a consistent match.



Matching Full Window Images
 

A common method of finding window images is to take a snapshot of the whole window, either by using the vTask "snapshot" button, or by pressing "Alt + PrintScreen" while the window is active. However, with Windows XP and greater, the upper corners of the window are transparent because they are rounded. These few pixels show that show what is behind the window are included in the image, and will change depending on whatever is behind the window at the moment.

To resolve this issue, make sure that the area behind windows stays the same color. This is not always possible, so another solution is to mask out the upper corners of the window:

    Change To:    




This will tell vTask to ignore any colors that change behind the window in these two corners. If you have problems when matching full windows, be sure to try this approach. Be sure to change the action to the correct "Masked" version of the same action.