Window name

The window name parameter for the UseWindow function is defined as :

<Executable module>|<Window class>|<Title>[|<Order number],[Instance number]

It is a delimited string. The fields within the string are separated by the "|" (pipe) character.

You can use the SPY tool to manually determine the caption of a window or Recording mode will record it automatically.

Title and class can be truncated in the script. This is useful when you want to use windows whose class is modified automatically by the application (for instance, a class in Word starts with Afx: but with a changing number after, for instance, Afx:0022).

Similarly, the title can be truncated. This is useful when part of the title is the name of a document.

For instance, if you want this:

UseWindow("WINWORD.EXE|OpusApp|Microsoft Word - Reference.doc",1)

to work when another Word document is loaded, just take out Reference.doc, as follows :

UseWindow("WINWORD.EXE|OpusApp|Microsoft Word - ",1)

Order number is used only if the 3 previous fields are not enough to make this window unique within the application. That is : when there are several objects of the same kind in the same window. For example, several edit fields are distinguished by this number :

Example with 2 comboboxes :

"ROBOHTML.EXE|ComboBox|RoboHELP HTML - WinTask |1"

and

"ROBOHTML.EXE|ComboBox|RoboHELP HTML - WinTask |2"

It is possible to truncate a window name as above but you must keep the order number, so a valid window name is: "ROBOHTML.EXE|ComboBox||1" (note the double || character).

 

Instance number can be omitted (or set to 0). In this case, the window name uses the first window found. If you launch an application several times, you must use an instance number to distinguish between the occurrences of the application. Instance numbers are assigned in the order in which the instances are launched, starting at 1.

Note: if a window with the exact name is not found, WinTask attempts a fuzzy match. It tries to find a window with approximately the same name by removing characters from the end of the title until eventually none is kept, and then the class (the first character is always kept). You can deactivate this mode with the system variable #UseExact. The switch to fuzzy-match mode is delayed: the delay is one-ninth of the value of #ActionTimeout, by default this is 3,33 sec (1/9 of 30 which is the default value of #ActionTimeout). However, if #ActionTimeout is less than or equal to 10, then only exact-match mode is used.

Examples

 

UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad", 1)
'Child window NOTEPAD , file "Untitled" opened, instance 1

 

UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad")

'Child window NOTEPAD , file "Untitled" opened, first instance found

 

UseWindow("NOTEPAD.EXE|Edit",1)

'Child window NOTEPAD , any file opened, instance 1