Watch and Close Window

Verb: watchAndCloseWindow

Available from: <Standard>

Watches for the opening of any new windows that match the defined criteria and closes it soon as it opens.

Syntax

watchAndCloseWindow [--useregex(Boolean)] [--title(String)] --regexPattern(String) [--regexOptions(DisplayableRegexOptions)] [--id(String)] [--classname(String)] [--processid(Numeric)] [--processname(String)] [--recursive(Boolean)] [--styles(Nullable<AutomationWindowStyles>)] [--minimumheight(Numeric)] [--minimumwidth(Numeric)] (CancellationTokenSource)=value

Inputs

Script Designer Required AcceptedTypes Description
--useregex Use Regular Expression Optional Boolean When enabled, allows the use of a regular expression to find the window that should be closed.
--title Title Optional Text Title of the window that should be closed.
--regexPattern Regular Expression Only whenUse Regular Expression is True Text Regular expression used to identify the window that should be closed.
--regexOptions Options Optional DisplayableRegexOptions Options for regular expression matching:
  • Compiled
  • Culture Invariant
  • ECMA Script
  • Explicit Capture
  • Ignore Case
  • Ignore Pattern Whitespace
  • Multiline
  • Right To Left
  • Singleline
  • --titleAsRegex Title is regular expression(Obsolete) Optional Boolean When enabled, allows the use of a "Regular Expression" to search for the window title.
    This parameter is obsolete, the Use Regular Expression parameter should be used instead.
    --ignorecase Ignore case(Obsolete) Optional Boolean When enabled, specifies case-insensitive matching.
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --dotmatchesnewline Dot matches new line(Obsolete) Optional Boolean When enabled, the dot (.) character matches every character, instead of every character except "\n".
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --freespacing Ignore white space(Obsolete) Optional Boolean When enabled, eliminates blank spaces and breaks without adding a escape character.
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --explicitcapture Explicit capture(Obsolete) Optional Boolean When enabled, specifies that the only valid captures are explicitly named or numbered groups of the form (? ).
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --multiline Multiline(Obsolete) Optional Boolean When enabled, changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --id Identifier Optional Text Id of the window that should be closed.
    --classname Class Name Optional Text Name of the class of the windows that should closed.
    --processid Process ID Optional Number Id of the process to which the window belongs.
    --processname Process Name Optional Text Name of the process to which the window belongs.
    --recursive Recursive Optional Boolean When enabled, closes windows within windows
    --styles Styles Optional AutomationWindowStyles Styles of the window that should be closed. Options:
  • Child
  • Dialog
  • --minimumheight Minimum Height Optional Number Minimum height of the window that should be closed.
    --minimumwidth Minimum Width Optional Number Minimum width of the window that should be closed.

    Outputs

    Script Designer AcceptedTypes Description
    value Cancel Token Source Cancellation Token Source Cancel token that can be used to cancel the command's continuous execution.

    Example

    The command watches for and closes two Notepad windows.

    defVar --name window --type Window
    defVar --name cancelToken --type CancellationTokenSource
    // Close the Notepad window whenever it opens.
    watchAndCloseWindow --useregex  --regexPattern "Notepad" --regexOptions "IgnoreCase" --processname notepad --recursive  cancelToken=value
    launchWindow --executablepath "C:\\Windows\\notepad.exe" window=value
    launchWindow --executablepath "C:\\Windows\\notepad.exe" window=value
    

    Remarks

    This command does not close windows already opened before it was used in the script.

    You can cancel the continuous execution of the Watch and Close Window command using the Cancel Token Source command and the token returned in the Cancel Token Source parameter.

    See Also

  • Attach Window
  • Cancel Token Source
  • Clear Cache
  • Click
  • Click on Cell
  • Click on Menu
  • Click on Value
  • Close Window
  • Control Screenshot
  • Count Windows
  • Expand Tree
  • Find Window
  • Find Windows
  • Focus
  • Focus Window
  • Get Barcode
  • Get Bounds
  • Get Cell Value
  • Get Control
  • Get Image Grid
  • Get Interval
  • Get Options
  • Get Table
  • Get Table Information
  • Get Tree Nodes
  • Get Value
  • Handle Open File Dialog
  • Handle Save File Dialog
  • Launch and Attach Window
  • Launch or Attach Window
  • Map Image Grid
  • Maximize or Minimize Window
  • Offset Value
  • Screenshot Window
  • Select Row
  • Select Tab
  • Set Execution Throttling
  • Set Grid Value
  • Set Value
  • Update Window
  • Verify Enabled
  • Verify If Visible
  • Wait and Close Security Window
  • Wait Busy Window
  • Wait Control
  • Wait for Control to Enable
  • Wait for Window to Appear