HotKey.SetScript
----------------

Sets which script to call if hotkey is pressed.

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

MBS( "HotKey.SetScript"; HotKeyRef; FileName; ScriptName { ; Parameter } ) 

**MBS**( **"HotKey.SetScript";** /\* Sets which script to call if hotkey is pressed. \*/  
**$HotKeyRef**; /\* The reference value for the hotkey as returned by [HotKey.Register](HotKeyRegister.md) function.e.g. $hotkey \*/   
**$FileName**; /\* The database file name where the script is located.e.g. "test.fmp12" \*/   
**$ScriptName**; /\* The script name.e.g. "MyScript" \*/   
**$Parameter**) /\* Optional; The parameter to pass.  
If empty or not defined, we pass the HotKey reference number. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| HotKeyRef | The reference value for the hotkey as returned by [HotKey.Register](HotKeyRegister.md) function. | $hotkey |  |
| FileName | The database file name where the script is located. | "test.fmp12" |  |
| ScriptName | The script name. | "MyScript" |  |
| Parameter | The parameter to pass.   If empty or not defined, we pass the HotKey reference number. |  | Optional |

### Result

Returns OK or error.

### Description

Sets which script to call if hotkey is pressed.  
Use [HotKey.GetTag](HotKeyGetTag.md) to query a tag value if needed.  
  
Default parameter passed to the script is the HotKey reference number. On macOS we include a second parameter to indicate whether it is KeyDown or KeyUp (see [HotKey.SetKeyUp](HotKeySetKeyUp.md)).  
  
  
With plugin version 6.0 or newer the script name can be a script ID number. In that case the plugin queries the script name for the given script ID. This allows to call scripts by ID and avoid problems if scripts are later renamed.  
  
Notice: FileMaker 19.2 adds a fmplugin extended privileges. If you have such an extended privileges to allow the plugin to trigger scripts, you need to grant permissions for it. If such a privilege is not defined, the plugin is allowed to trigger scripts. See FileMaker product documentation for details.  
### Examples

Register Control-F5:

 Set Field \[HotKeys::HotKey ID; MBS ("[HotKey.Register](HotKeyRegister.md)"; "F5"; "control")\]  
Set Variable \[$r ; Value:MBS ("HotKey.SetScript"; HotKeys::HotKey ID; Get(FileName); "HotkeyAction")\]  
### See also

- [HotKey.GetTag](HotKeyGetTag.md)
- [HotKey.Register](HotKeyRegister.md)
- [HotKey.SetKeyUp](HotKeySetKeyUp.md)
- [HotKey.SetLocal](HotKeySetLocal.md)
- [HotKey.SetName](HotKeySetName.md)
- [HotKey.SetScriptWorkspaceOnly](HotKeySetScriptWorkspaceOnly.md)
- [HotKey.SetTag](HotKeySetTag.md)

### Release notes

- **Version 12.1**
    - Added parameter as optional parameter for [HotKey.SetScript](https://www.mbsplugins.eu/HotKeySetScript.shtml) function to overwrite default parameter.
- **Version 10.2**
    - Added [HotKey.SetScriptWorkspaceOnly](https://www.mbsplugins.eu/HotKeySetScriptWorkspaceOnly.shtml) and [HotKey.GetScriptWorkspaceOnly](https://www.mbsplugins.eu/HotKeyGetScriptWorkspaceOnly.shtml) functions.

### Example Databases

- [HotKeys](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/HotKeys.shtml#2ScriptAnchor_)
- [Window/Popover CardWindow](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/Popover%20CardWindow.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 19 - Hot Keys](https://www.mbsplugins.de/archive/2024-12-19/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.1pr4](https://www.mbsplugins.de/archive/2022-02-22/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2026, Seite 9](https://filemaker-magazin.de/neuigkeit/4312-Die-neue-Ausgabe-FMM_202601-steht-online)

This function is free to use.

Created 4th February 2015 , last changed 20th February 2022

  
[HotKey.SetPermanent](HotKeySetPermanent.md) - [HotKey.SetScriptWorkspaceOnly](HotKeySetScriptWorkspaceOnly.md)

[HTML Version](HotKeySetScript.shtml)