Child window commands are responsible for triggering behaviour when a dialog (child window) of the monitored process opens.
Waits until a window (dialog box) child of the target app, whose caption matches the parameter value and the optional control matching options, comes to the foreground. When it does the script within the conditional statement block is executed.
If a timeout is specified and the window is not detected before the timeout expires then the script is terminated and follows the OnError
settings.
Refer to the syntax diagrams for the valid combinations and positioning of the parameters.
Parameter | Meaning |
---|---|
| Default option if none is specified. The code block is executed only on the first time the window instance comes to the foreground. |
| The code block is executed every time the window instance comes to the foreground. |
The Poll
option causes the desktop client to periodically check if the foreground window is the one it is looking for. Normally this is automatic, but some applications don’t behave as expected and this may resolve the issue.
If a window with caption “Hello World” comes to the foreground then the script within the { }s is executed.
WhenWindow "Hello World"
{
// More script
}
The following example is triggered when a window with the caption “About ACME CMS” comes to the foreground and one of the text fields on the window contains the username used to log into the app.
WhenWindow "About ACME CMS" ControlStatic bmUsername
{
// Select the button that has the user's name as its caption
SelectControl ControlButton EndsWith bmUsername
// Press the button
SendKeys ENTER
}
WhenWindow
only works on windows belonging to the process being scripted. (The one identified by the WaitProcess
command.)
It is possible to use a WhenWindow
on the main window of an application but this may interfere with the normal running of the application, so should be used carefully. It is more likely that the WhenVaultLaunch command should be used instead.
The Control Select Options allow for finer level control over matching of a window (in a WhenWindow
command) or in selecting a control (in the SelectControl
command).
This is achieved by defining a pattern that identifies a specific control within the target window.
Refer to the syntax diagrams for the valid combinations and positioning of the parameters.
The type of control. Valid values are:
ControlButton
ControlComboBox
ControlEdit
ControlListBox
ControlMdiClient
ControlScrollBar
ControlStatic
(text labels)
One way to identify the type of a control is to use a tool like WinSpy that shows the underlying windows control’s class name.
The screen grabs below show WinSpy identifying button, edit and label (static) controls.
The string value to be matched against the control’s content.
How the control content pattern is to be matched to the control’s text.
These are all case insensitive.
Default value is Contains
.
StartsWith
The control’s text must start with the value.
Contains
The control’s text must contain the value.
EndsWith
The control’s text must end with the value.
Regex
The control content pattern is treated as a regex and an IsMatch performed between it and the control’s text.
Matches the n’th control that satisfies all the above filter criteria.
First matching control’s index is 1.
Default value is 1.
If no control content pattern is specified then the index will simply allow the n’th instance of a specific control to be matched.
Matches against the specified control class if a control of that type has the supplied ID. The Control ID is assumed to be unique to a search, so the first time a match is found it is selected.
Specified as a 32 bit hexadecimal number in the format 0x[0-9, a-f, A-F]
E.g. 0x120F or 0x120f
Default value is to not use the control ID.
The following table summarises the effect of using the above parameters in combination.
Class | Content Pattern | Index | Result |
---|---|---|---|
Specified | Not Specified | Default | Selects the first control of the control class type |
Specified | Not Specified | Specified | Selects the index(th) control of the control class type |
Specified | Specified | Default | Selects the first control that matches the type and content |
Specified | Specified | Specified | Selects the index(th) control that matches the type and content |