Search Control

Verb: searchControl

Finds an instance of a control according to the defined parameters.

Syntax

searchControl [--window(String)] [--indexedpath(String)] [--id(String)] [--name(String)] [--innertext(String)] [--elementvalue(String)] [--classname(String)] [--controltype(String)] [--index(Numeric)] [--width(Numeric)] [--height(Numeric)] [--timeout(TimeSpan)] (Boolean)=success (Control)=value

Inputs

Script Designer Required AcceptedTypes Description
--window Window Optional Text, Window Title or variable with the control window.
--indexedpath Index path Optional Text Control Index Path.
Index Path is based on Microsoft Active Accessibility (MSAA) technology. The path of the tree nodes is separated by a comma and each index corresponds to an element. The Search Control command will employ MSAA indexed path search only when indexedpath is set, Otherwise, it uses UIAutomation API search. All selectors are evaluated using the AND logical conjuction with the MSAA indexed path always being the first one to be evaluated. Even if indexedpath is set, at the end, the object is converted into an UIAutomation handle.
--id Id Optional Text ID of the control that should be found.
--name Name Optional Text Name of the control that should be found.
--innertext Text Optional Text Inner text of the control that should be found.
--elementvalue Element Value Optional Text Element value of the control that should be found.
--classname Class Optional Text Class of the control that should be found.
--controltype Type Optional Text Type of the control that should be found.
--index Index Optional Number Index of the control that should be found.
--width Control Width Optional Number Exact width of the control that should be found.
--height Control Height Optional Number The height of the control that should be found.
--timeout Timeout Optional Time Span, Number, Text Maximum time limit to execute the command. If no value is defined for the timeout parameter, the execution uses the context timeout defined by the Set Timeout command. If that command is not used on the script, the default timeout is 5 seconds.

Outputs

Script Designer AcceptedTypes Description
success Success Boolean Returns "True", if the control was found, or "False" otherwise.
value Control Control Returns the instance of the control.

Example

An instance of "Notepad" is started without being attached to a context, so the Search Control command finds that instance and attaches it to the current context, after that, the text file is saved on the user's Desktop.

defVar --name controlInstance --type Control
defVar --name successSearch --type Boolean
defVar --name desktopPath --type String
defVar --name successSave --type Boolean
getSpecialFolder --folder "Desktop" desktopPath=value
openFile --file "notepad.exe"
searchControl --window "Untitled - Notepad" --indexedpath "3,1,1,4" --timeout 01:01:00 --comment "File -> Save as" successSearch=success controlInstance=value
logMessage --message "\r\n${successSearch}" --type "Info"
if --left "${successSearch}" --operator "Is_True"
        click --selector "Instance" --control ${controlInstance}
endIf
handleSaveFileDialog --filepath "${desktopPath}\\Example.txt" successSave=success
logMessage --message "\r\n${controlInstance.Window.Title}\r\n${successSave}" --type "Info"

Remarks

  • The Index path parameter also accepts negative values. If "-1" is entered, the last element of the tree will be fetched; if "-2" is entered, the one before that will be fetched and so on.
  • 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
  • Show or Hide Element
  • 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
  • Wait for Window to Close
  • Watch and Close Window