Menubar.RunMenuCommand
----------------------

Runs a menu command.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Menubar](component_Menubar.md) | [5.0](newinversion50.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "Menubar.RunMenuCommand"; Path { ; Delay } ) 

**MBS**( **"Menubar.RunMenuCommand";** /\* Runs a menu command. \*/  
**$Path**; /\* The ID or path to the menu entry.  
Use [Menubar.ListMenuCommands](MenubarListMenuCommands.md) to find out the IDs and names.e.g. 49297 \*/   
**$Delay**) /\* Optional; for macOS an optional delay to run the command after seconds.  
e.g. pass 0.1 to run command after 100ms. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | The ID or path to the menu entry.   Use [Menubar.ListMenuCommands](MenubarListMenuCommands.md) to find out the IDs and names. | 49297 |  |
| Delay | for macOS an optional delay to run the command after seconds.   e.g. pass 0.1 to run command after 100ms. |  | Optional |

### Result

Returns OK or error.

### Description

Runs a menu command.  
The plugin searches menu command and invokes it.  
For Windows, the command is run asynchronously, so the function returns before the command runs. You may need to make a script pause to run the command.  
  
For a couple of menu commands you may need to use [Schedule.EvaluateAfterDelay](ScheduleEvaluateAfterDelay.md) to make sure the plugin invokes the menu after the script finished running.  
### Examples

Run command to select all:

 MBS ("Menubar.RunMenuCommand"; "Bearbeiten¶Alles auswählen")  
Show debugger:

 MBS ("Menubar.RunMenuCommand"; "Werkzeuge¶Script-Debugger")  
Show debugger from within a script:

 #The menu command as we got it from [Menubar.ListMenuCommands](MenubarListMenuCommands.md)  
Set Variable \[$DebuggerMenuID ; Value:49260\]  
If \[MBS ( "[Menubar.HasMenuCommand](MenubarHasMenuCommand.md)"; $DebuggerMenuID ) = 1\]  
 If \[MBS ( "[Menubar.IsMenuCommandChecked](MenubarIsMenuCommandChecked.md)"; $DebuggerMenuID ) = 1\]  
 #debugger already visible  
 Else  
 #show debugger  
 Set Variable \[$r ; Value:MBS ( "Menubar.RunMenuCommand"; $DebuggerMenuID )\]  
 Pause/Resume Script \[Duration (seconds): ,1\]  
 End If  
Else  
 Show Custom Dialog \["Debugger missing in Menubar?"\]  
End If  
\#now follows your script that should always run in debugger   
Show/Hide format bar in German:

 Set Variable \[ $r ; Value: MBS ( "[Schedule.EvaluateAfterDelay](ScheduleEvaluateAfterDelay.md)"; ,1; "MBS ( \\"Menubar.RunMenuCommand\\"; Liste(\\"Ansicht\\"; \\"Formatierungsleiste\\") )") \]  
Make snapshot link with F5 hotkey:

 Set Variable \[ $$Hotkey ; Value: MBS ("[HotKey.Register](HotKeyRegister.md)"; "F5"; "") \]   
Set Variable \[ $r ; Value: MBS ( "[HotKey.SetEvaluate](HotKeySetEvaluate.md)"; $$Hotkey ; "MBS ( \\"Menubar.RunMenuCommand\\"; 50285 )" ) \]  
Enter layout mode in a second:

 Set Variable \[ $r ; Value: MBS ( "[Schedule.EvaluateAfterDelay](ScheduleEvaluateAfterDelay.md)" ; 1 ; "MBS ( \\"Menubar.RunMenuCommand\\" ; 49156 )" ) \]  
Toggle formatting bar:

 Set Variable \[ $r ; Value: MBS ( "Menubar.RunMenuCommand"; "50204"; 1 ) \]  
### See also

- [HotKey.Register](HotKeyRegister.md)
- [HotKey.SetEvaluate](HotKeySetEvaluate.md)
- [Menubar.HasMenuCommand](MenubarHasMenuCommand.md)
- [Menubar.IsMenuCommandChecked](MenubarIsMenuCommandChecked.md)
- [Menubar.ListMenuCommands](MenubarListMenuCommands.md)
- [PageSetupDialog.Enable](PageSetupDialogEnable.md)
- [PageSetupDialog.Install](PageSetupDialogInstall.md)
- [Schedule.EvaluateAfterDelay](ScheduleEvaluateAfterDelay.md)
- [SyntaxColoring.AddContextMenuCommand](SyntaxColoringAddContextMenuCommand.md)
- [TouchBar.AddButton](TouchBarAddButton.md)

### Example Databases

- [HotKeys](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/HotKeys.shtml#5ScriptAnchor_)
- [Mac only/Print/Page Setup Dialog on Mac](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/Print/Page%20Setup%20Dialog%20on%20Mac.shtml#2ScriptAnchor_)
- [Mac only/Print/Page Setup Dialog](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/Print/Page%20Setup%20Dialog.shtml#1ScriptAnchor_)
- [Mac only/TouchBar](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/TouchBar.shtml#1ScriptAnchor_)
- [SQL in FileMaker/Custom Functions to Log Scriptcalls](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20in%20FileMaker/Custom%20Functions%20to%20Log%20Scriptcalls.shtml#2ScriptAnchor_)
- [Win Only/Search Scripts](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/Search%20Scripts.shtml#1ScriptAnchor_)
- [Win Only/Snippets for Windows](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/Snippets%20for%20Windows.shtml#1ScriptAnchor_)

### Blog Entries

- [Goodies 33: Custom context menu commands for FileMaker ScriptWorkspace](https://www.monkeybreadsoftware.com/filemaker/SyntaxColoring/33-CustomcontextmenucommandsforFileMakerScriptWorkspace.shtml)
- [MBS FileMaker Advent calendar - Door 23 - Printing a PDF](https://www.mbsplugins.de/archive/2024-12-23/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Define a hotkey to copy field name for layout objects in FileMaker](https://www.mbsplugins.de/archive/2024-11-09/Define_a_hotkey_to_copy_field_/monkeybreadsoftware_blog_filemaker)
- [Adding ChatGPT to the ScriptWorkspace context menu](https://www.mbsplugins.de/archive/2024-09-18/Adding_ChatGPT_to_the_ScriptWo/monkeybreadsoftware_blog_filemaker)
- [Data Viewer extensions](https://www.mbsplugins.de/archive/2023-01-11/Data_Viewer_extensions/monkeybreadsoftware_blog_filemaker)
- [New functions of the MBS Plugin Version 9.5](https://www.mbsplugins.de/archive/2019-11-21/New_functions_of_the_MBS_Plugi/monkeybreadsoftware_blog_filemaker)
- [Define hot keys for functions in the FileMaker development](https://www.mbsplugins.de/archive/2019-11-15/Define_hot_keys_for_functions_/monkeybreadsoftware_blog_filemaker)
- [Add a search and replace command for FileMaker Script Workspace](https://www.mbsplugins.de/archive/2019-11-14/Add_a_search_and_replace_comma/monkeybreadsoftware_blog_filemaker)
- [Custom context menu commands for FileMaker ScriptWorkspace](https://www.mbsplugins.de/archive/2019-10-19/Custom_context_menu_commands_f/monkeybreadsoftware_blog_filemaker)
- [Page Setup Dialog example](https://www.mbsplugins.de/archive/2019-06-01/Page_Setup_Dialog_example/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2020, Seite 28 bis 29](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)

This function checks for a license.

Created 15th November 2014 , last changed 28th June 2024

  
[Menubar.RemoveMenuCommand](MenubarRemoveMenuCommand.md) - [Menubar.SetMenuCommandShortcut](MenubarSetMenuCommandShortcut.md)

[HTML Version](MenubarRunMenuCommand.shtml)