Click on Menu

Clicks on menu items in an open window.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

clickOnMenu --window(Window) --menupath(String) [--timeout(TimeSpan)]


You must use another command that opens a window, such as Launch and Attach Window (launchWindow) or Attach Window (attachWindow).

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Window window Optional Window Open window in which the menu is clicked. This parameter also works with SAP windows.
Path menupath Required Text Text of the menu item. Each menu item that will be clicked must be separated by a line break.
Timeout timeout Optional Time Span, Number, Text Command execution time. If no value is defined in the Timeout parameter, the command uses the context time defined by the Set Timeout (setTimeout) command. If the script does not use that command, the default time is 5 seconds.


Example 1: A Notepad application window opens. The Click on Menu command performs the following sequence of clicks in the menu: File > Open, which opens a new window for selecting a file.

defVar --name notepadWindow --type Window
defVar --name processId --type Numeric
defVar --name success --type Boolean
launchWindow --executablepath "C:\\Windows\\notepad.exe" --timeout 00:00:20 notepadWindow=value  processId=processId success=success
clickOnMenu --window ${notepadWindow} --menupath "file\r\nopen" --timeout 00:00:10

Example 2: Similar to the previous example, however, to go through the menus several times, several executions of the Click on Menu command are necessary.

defVar --name notepadWindow --type Window
launchWindow --executablepath "C:\\Windows\\notepad.exe" --timeout 00:00:20 notepadWindow=value
typeText --text "IBM"
clickOnMenu --window ${notepadWindow} --menupath "edit\r\nselect all" --timeout 00:00:10
clickOnMenu --window ${notepadWindow} --menupath "edit\r\ncut" --timeout 00:00:10
clickOnMenu --window ${notepadWindow} --menupath "edit\r\npaste" --timeout 00:00:10
clickOnMenu --window ${notepadWindow} --menupath "file\r\nsave" --timeout 00:00:10
// Write, select, cut and paste text and open the save file window.

Example 3: This example shows how the command works with SAP. It starts a SAP session, and opens an SAP task based on the defined transaction code.

startSAPSession --applicationpath "path\\sap.exe" --connectionstring "Connection string" --clientid 001 --username username --password password --language en
sapTransaction --transactionCode "Transaction code"
click --selector "Id" --controlsimilarity 100 --id "wnd[0]/usr/ssubSUBSCREEN_0:SAPWL_ST03N:1200/cntlALV_OVERVIEW_CONTAINER/shellcont/shell/Toolbar(13)"
clickOnMenu --menupath "Word processing" --timeout "00:00:10"

Example 4: The Calculator application is open, a control is obtained, and the command clicks on a menu based on the control previously obtained.

defVar --name calculatorID --type String
defVar --name id --type Control
defVar --name calculatorWindow --type Window
// Open the Calculator application
launchWindow --executablepath "calc.exe" --safesearch  calculatorWindow=value
// Get ID as control
getControl --selector "Id" --id "${calculatorID}" id=control
// Click on the menu based on the control obtained previously
clickOnMenu --window ${calculatorWindow} --menupath "${id}" --timeout "00:00:10"
Remember:The examples above do not work on Windows 11. IBM RPA does not support Windows 11 UWP applications.