Window.RunCommand
-----------------

Performs a function on a window.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Window](component_Window.md) | [6.5](newinversion65.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |

MBS( "Window.RunCommand"; WindowRef; Command ) 

**MBS**( **"Window.RunCommand";** /\* Performs a function on a window. \*/  
**$WindowRef**; /\* Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window.e.g. 0 \*/   
**$Command**) /\* The name of the command. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| WindowRef | Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window. | 0 |
| Command | The name of the command. |  |

### Result

Returns OK or error.

### Description

Performs a function on a window.  
Please use [Window.ListCommands](WindowListCommands.md) to find available commands.  
Please run as last command in script, so the function can do the job properly.  
  
Be aware that this is not supported by FileMaker. Some commands work correctly, but others do nothing or can crash FileMaker.  
### Examples

Shows dialog to customize table fields:

 Set Variable \[$r ; Value:MBS ("Window.RunCommand"; 0; "onModifyTableView")\]  
Zooms window:

 Set Variable \[$r ; Value:MBS ("Window.RunCommand"; 0; "zoom")\]  
Close window:

 Set Variable \[ $r ; Value: MBS ( "Window.RunCommand"; 0; "performClose" ) \]  
Toggle fullscreen:

 Set Variable \[ $r ; Value: MBS ( "Window.RunCommand"; 0; "toggleFullScreen" ) \]  
Toggle toolbar:

 Set Variable \[ $r ; Value: MBS ( "Window.RunCommand"; 0; "toggleToolbarShown" ) \]  
Show toolbar configuration sheet:

 Set Variable \[ $r ; Value: MBS ( "Window.RunCommand"; 0; "runToolbarCustomizationPalette" ) \]  
### See also

- [Window.FindByIndex](WindowFindByIndex.md)
- [Window.FindByTitle](WindowFindByTitle.md)
- [Window.List](WindowList.md)
- [Window.ListCommands](WindowListCommands.md)

### Blog Entries

- [MBS FileMaker Plugin, version 6.5pr9](https://www.mbsplugins.de/archive/2016-12-05/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 27th November 2016 , last changed 1st November 2020

  
[Window.ResizeContentView](WindowResizeContentView.md) - [Window.RunToolbarCustomizationPalette](WindowRunToolbarCustomizationPalette.md)

[HTML Version](WindowRunCommand.shtml)