Identifying Windows and Controls


Nearly everything visible on the screen is some type of window. vTask primarily interacts with windows while running actions. Input controls, such as buttons and checkboxes, are also windows. Understanding windows and how to identify them is important when using vTask.

It is necessary that windows can be uniquely identified, or automation scripts will not work correctly. For example, there may be multiple "OK" buttons on the screen at any given moment, so a "Click OK" command would not execute as expected. To be able to distinguish windows, vTask utilizes various window properties:

Title - the window text, such as "Untitled - Notepad" (also the text of edit fields)
Exact Title - same as "Title", however the match must be exact in case and length
Class - the type of window/control, such as "Button"
ID - the identifier of the control, such as "1001"
Userdata - internal data of the window, set by the program (this is not the text data)
Handle (HWND) - the window handle (assigned by the operating system)
Image - the onscreen bitmap of the window/control

Each identifier data value is separated by the pipe character '|', therefore to search on the combination of class and ID, you would use "Edit|1002". To automatically retrieve these values with vTask, use the Magnify tool:



NOTE: If you change the combination of properties for window identification, you will need to locate the window again with the Magnify tool, or modify the search text information by hand. For example, if you are searching for Title+Class, the text will be something like "OK|Button", but if you remove "Title" you will also need to remove "OK|" from the search text. This is not done automatically.

*Tip:  Do not use Title to identify Text Boxes (Edit Fields), as that will continually change if the text in the box is updated by the user.


Usually a combination of identifiers works best:

For program windows, use Title, or Title + Class
For controls, use Class + ID + Userdata (plus Title if it's a button)
For web links and graphics, use Bitmap Image


*Tip:  Image matching is the overall best method of identifying controls, and may be the only method for certain items such as graphic web links.


If suspect that window identification is not working properly, be sure to use the Tools - Display All Windows and Controls menu option. Search for the window's information that you are trying to identify. Chances are, there are multiple windows with the same information, confusion between ID and Userdata, or some similar conflict.

*Tip:  Tools - Display All Windows and Controls is the most useful tool for investigating windows identification problems.


Things such as Coordinates, Size or Proc Address are not used for identification because they change each time a program is run. Here are a few examples of typical window identifiers:

Window / Control How to Locate
Title:   "OK"
Class:   "Button"
ID:   "1001"
Userdata:   "0"
Title:   "123."
Class:   "Edit"
ID:   "403"
Userdata:   "0"
Title:   "Microsoft Excel - Book1"
Class:   "XLMAIN"
ID:   "0"
Userdata:   "0"
Title:   "Standard"
Class:   "MsoCommandBar"
ID:   "0"
Userdata:   "0"
(web control inside of browser)
Recommended Identifier:   Image-based

For situations that require interacting with web pages, either use Keyboard Commands, or use image-based actions.

Using images allows you to interact with the page regardless of the web browser that is used, and regardless of the location of the image on the screen. See Using Images for a full description. For this example, a good "identifying image" would be:


...and the following command would take the mouse to the login field:



This image-based mouse action will perform the actions that you need at the right location.


If vTask finds multiple window matches using the criteria, a failure will be generated. You can turn off this warning in the Tools - Options screen.

When using the Title match method, vTask checks windows in the following order (however "Exact Title" match option overrides this order):

1) Exact title match for applications
2) Case insensitive title match for applications
3) Partial title match for applications
4) Exact title matches for popup windows
5) Case insensitive title matches for popup windows
6) Exact title match for any window or control
7) Partial, Case insensitive match for any window or control

This order ensures that main application windows such as "Microsoft Excel" get priority during activation before small windows or controls. This also allows you to enter in a portion of the window title for situations where it will change during runtime.

If you provide the exact window title of the window you are looking for, then vTask will first find it before the other ones. As noted above, vTask first does a case-sensitive, exact lookup of all window titles. If it finds a match, then it uses that title and doesn't look any further. Therefore, vTask only uses a less restrictive match if an exact match can't be found.

Locating a .NET control is more difficult, because the class name may change each time the program is run. To find a dot Net control, use the class name with an asterisk (wildcard), which will match any windows that begin with the class name:



If vTask cannot find a window, and you are sure it exists, use the Tools - Display Windows command. It will list all windows running in the system. If a window isn't listed, then it doesn't exist in the system. A program such as Microsoft Spy++ will list the same window information.