Window Not Found
The UseWindow function provides synchronization within the script, temporarily blocking script execution until the window with the name as specified in UseWindow argument exists and is ready for input.
If the window with a name as specified in UseWindow cannot be found within the default timeout period of 30 seconds, the function will fail.
If the window name is the correct one as shown on the desktop at replay, but the window does not show within the default timeout period, the amount of time can be increased via the #ActionTimeout system variable. The #ActionTimeout variable can be increased just before the UseWindow function and then restored to it's original value immediately following it.
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.
The default behavior of the UseWindow function is to allow the script to continue execution as soon as a window with the exact window name as specified in UseWindow exists on desktop and is ready for input. If after #ActionTimeout/10 seconds (as #ActionTimeout default value is 30, the value is 3 secs unless you change #ActionTimeout value), no window with the specified name is found, a "fuzzy match" search starts. WinTask searches a window whose name has the same executable module and the same first characters for the window class as the one specified in the script.
You can change this default behavior by setting the #UseExact system variable to 1 before the UseWindow function. The UseWindow function will now wait for the window to be there with the fully specified window name, and fails no window with the exact window name is found.
The complement to the exact matching behavior invoked by setting the #UseExact system variable to 1 is to use "wildcards" in the UseWindow function. Wildcard behavior is invoked by truncating characters from the end of the window name. Truncation is allowed until the first character of the window class.
To allow the recogniton of any Word window whatever document is loaded, truncate
UseWindow("WINWORD.EXE|OpusApp|Microsoft Word - Referenc.doc",1)
Use the following step-by-step instructions to help diagnose and correct the Window not found error message.
- Execute the script in question.
- When the script fails and displays the error message, click the OK button to dismiss the message box. Do not close any window on the desktop.
- If it appears that the window is now there, you may have a synchronization error. See above how to increase the default timeout. Continue with the next step if the problem persists.
- If the correct window page is displayed and ready for input, there may be a problem with the window name. Bring up the WinTask Editor and create a new script.
- Start Recording Mode. Select the Nothing radio button on the Start Recording Mode dialog box and click the OK button.
- Return to the desktop and manually execute the steps on the window that the script was attempting to automate.
- Stop Recording Mode. Your actions will be inserted into the new WinTask script. Restore the application on the desktop to the state it was at when the failure occurred.
- Save the newly recorded script. Compile and execute the script.
- If the new script replays correctly, compare the newly generated window name with the corresponding one in the script with the error. Look carefully at the instance number if multiple instances of the automated application are loaded.
- If the window name in the new script differs from the original script, update the original script so the window name matches the new script. Recompile and execute the script.
- If the script still fails after trying all of the above recommendations, please contact us for further assistance.