17.6.1 Window processing
During remote installation, the user at a destination computer might respond to dialog boxes or use the keyboard or mouse by mistake. If so, remote installation might stop. In the MAIN section, you must code the main processing, while taking possible interruptions into consideration.
The following figure shows the window processing in an AIT file:
The AIT file is coded to repeat a loop that finds and operates windows. Therefore, if the user at the computer responds to Window A by mistake and Window B appears as a result, the Automatic Installation Tool might skip the processing for Window A and execute the processing for Window B instead.
When creating an AIT file, you check the windows displayed during installation, and list the operations on the windows. These operations are coded in a loop. This processing structure allows you to complete the processing regardless of the order of the output windows and user operations.
In an AIT file, the processing for windows must be sequentially coded in the loop. The processing of each window is coded as a set of the following processes:
-
Finding a window
-
Operating the found window
These processes are coded using the API functions listed in Tables 16-2 and 16-3.
API |
Description |
---|---|
AIT_FocusWindow |
Finds a window, and sets the focus on the window. |
AIT_CtrlSetFocus |
Sets the focus on a specific control. |
- Note on window processing
-
This note applies when you use an AIT file to remotely install software in any of the following OS environments: Windows Server 2019, Windows Server 2016, Windows 10, Windows 8.1, Windows 8, Windows Server 2012, Windows 7, or Windows Server 2008 R2. In this case, the APIs for window operations (AIT_FocusWindow and AIT_CtrlSetFocus) might not be able to set the focus in the application. In such cases, execute either of the API functions AIT_Exec and AIT_ExecCommand, which are used for recorder operations, and then use AIT_PlayKey to simulate the pressing of the Alt + Tab keys to move the focus from the desktop.
The following describes the roles of these API functions, and explains how to use them. For details about the parameters and return values for the API functions, see Chapter 19. API Function Reference.
- Organization of this subsection
(1) AIT_FocusWindow
AIT_FocusWindow finds a window, and sets the focus on the window. Before starting the operations on the target window, you must find it and set the focus on it.
When you find a window, you need to specify the window text and class name of the window as parameters. To identify the window text and the class name, you can conveniently use the Window Properties tool. For this purpose, you can also use the codes in the AIT file generated automatically by the Recorder.
If the target window is found, the API function returns the handle to the window; otherwise, it returns 0.
The following gives an example of using AIT_FocusWindow.
(2) AIT_CtrlSetFocus
AIT_CtrlSetFocus sets the focus on a specific control. If the window contains multiple controls, use AIT_CtrlSetFocus to set the focus on the target control, then simulate user operations.
The target control is specified with its caption or control ID, as well as the control type (such as button or list box).
The following gives an example of using AIT_CtrlSetFocus with the caption of a control specified.
(3) AIT_VerifyExistence
AIT_VerifyExistence checks whether the control exists on the window.
For example, if there are windows that have the same caption, the window found by AIT_VerifyExistence is not always the target window that you want to operate. In such a case, you can use AIT_VerifyExistence to check whether the window contains the desired control, and to determine whether the window is the target to be operated.
The target control is specified with its caption or control ID, as well as the control type (such as button or list box). If the target control exists, this API function returns 1; otherwise it returns 0.
The following gives an example of using AIT_VerifyExistence with the caption of a control specified.
(4) AIT_VerifyEnabled
AIT_VerifyEnabled checks whether the control is enabled.
For example, suppose buttons are associated with a check box, and they are enabled when the check box is selected and are disabled when it is not selected. In such a case, you can use AIT_VerifyEnabled to check whether the button is enabled. If the button is enabled, a simulation of the actions that occur when a user clicks the button is performed.
AIT_VerifyEnabled is used in combination with AIT_VerifyExistence or AIT_VerifyPos. After the existence of the target control is verified with AIT_VerifyExistence or AIT_VerifyPos, AIT_VerifyEnabled is used to check whether the control is enabled.
The target control is specified with its caption or control ID, as well as the control type (such as button or list box). If the target control is enabled, this API function returns 1; otherwise it returns 0.
The following gives an example of using AIT_VerifyEnabled with the caption of a control specified.
(5) AIT_VerifyPos
AIT_VerifyPos checks the tab order of the control. Similar to AIT_VerifyExistence, AIT_VerifyPos is also used to check whether the target control exists. However, if there are controls that have the same caption in the window, the target control cannot be identified by the caption only. In such a case, the target control can be identified by using AIT_VerifyPos with the tab order of the target control specified.
The target control is specified with its caption or control ID, as well as the control type (such as button or list box) and tab order. If the specified tab order matches that of the control, this API function returns 1; otherwise it returns 0.
The following gives an example of using AIT_VerifyPos with the caption of a control specified.
(6) AIT_PlayKey
AIT_PlayKey simulates a keyboard operation.
In this API function, you can specify characters to be entered or keys to be pressed. For example, when the character string abcd is specified, this API function enters it as if you typed. When {ESC} is specified, this API function simulates pressing Esc, and when %(F) is specified, it simulates pressing the Alt+F shortcut key.
The following gives an example of using AIT_PlayKey.
(7) Example of automatically generated codes for window processing
In an AIT file automatically generated by the Recorder, window information and your operations on windows are recorded. The following figure shows an example of automatically generated code for window processing.