HotKey.SetEvaluate
------------------

Sets expression to be run when hotkey is pressed.

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

MBS( "HotKey.SetEvaluate"; HotKeyRef; Expression ) 

**MBS**( **"HotKey.SetEvaluate";** /\* Sets expression to be run when hotkey is pressed. \*/  
**$HotKeyRef**; /\* The reference value for the hotkey as returned by [HotKey.Register](HotKeyRegister.md) function.e.g. $hotkey \*/   
**$Expression**) /\* The expression to evaluate.  
Can be in local language of FileMaker Pro or english.   
For Server must always be in english.e.g. "Let ( $$Done = 1 ; 1 )" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| HotKeyRef | The reference value for the hotkey as returned by [HotKey.Register](HotKeyRegister.md) function. | $hotkey |
| Expression | The expression to evaluate.   Can be in local language of FileMaker Pro or english.    For Server must always be in english. | "Let ( $$Done = 1 ; 1 )" |

### Result

Returns OK or error.

### Description

Sets expression to be run when hotkey is pressed.  
In the expression the text $$ID$$ will be replaced when evaluated with the hotkey reference, so you can pass it to other functions if needed.  
### Examples

Sets expression to run when hotkey is pressed:

 Set Variable \[ $result ; Value: MBS ( "HotKey.SetEvaluate"; $hotkey ; "Let ( $$Cancelled = 1 ; 1 )" ) \]  
Set to write to a log file when a key is pressed:

 MBS ( "HotKey.SetEvaluate"; $hotkey ; "MBS (\\"[Text.AppendTextFile](TextAppendTextFile.md)\\"; Get(CurrentHostTimeStamp) &amp; \\": Key F5 pressed¶\\"; \\"/Users/cs/Desktop/hotkey.txt\\"; \\"native\\")")  
Register Control-F5 for showing/hiding data viewer:

 Set Variable \[$hotkey ; Value:MBS ("[HotKey.Register](HotKeyRegister.md)"; "F5"; "control")\]  
Set Variable \[$r ; Value:MBS ( "HotKey.SetEvaluate"; $hotkey ; "MBS (\\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 49297)" )\]  
Register Control-F5 to write text file on desktop with content of data viewer:

 MBS ( "HotKey.SetEvaluate";   
 MBS ("[HotKey.Register](HotKeyRegister.md)"; "F5"; "control");   
 "MBS ( \\"[Text.WriteTextFile](TextWriteTextFile.md)\\";   
 MBS ( \\"[FM.DataViewerContent](FMDataViewerContent.md)\\" );   
 MBS ( \\"[Path.AddPathComponent](PathAddPathComponent.md)\\";   
 MBS ( \\"[Folders.UserDesktop](FoldersUserDesktop.md)\\" );   
 \\"Data Viewer \\" &amp; substitute(substitute(Get(CurrentTimestamp); \\":\\"; \\"-\\"); \\"/\\"; \\"-\\") &amp; \\".txt\\" );   
 \\"UTF-8\\"   
 )"  
)  
Register Control-F6 to write current script a text file to desktop:

 MBS ( "HotKey.SetEvaluate";   
 MBS ("[HotKey.Register](HotKeyRegister.md)"; "F6"; "control");   
 "MBS ( \\"[Text.WriteTextFile](TextWriteTextFile.md)\\";   
 MBS ( \\"[ScriptWorkspace.ScriptText](ScriptWorkspaceScriptText.md)\\" );   
 MBS ( \\"[Path.AddPathComponent](PathAddPathComponent.md)\\";   
 MBS ( \\"[Folders.UserDesktop](FoldersUserDesktop.md)\\" );   
 \\"Script \\" &amp; substitute(substitute(MBS ( \\"[ScriptWorkspace.CurrentTab](ScriptWorkspaceCurrentTab.md)\\" ); \\":\\"; \\"-\\"); \\"/\\"; \\"-\\") &amp; \\".txt\\" );   
 \\"UTF-8\\"   
 )"  
)  
### See also

- [App.GetFocussedWindowTitle](AppGetFocussedWindowTitle.md)
- [FM.DataViewerContent](FMDataViewerContent.md)
- [FM.RunScript](FMRunScript.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [Menubar.RunMenuCommand](MenubarRunMenuCommand.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [ScriptWorkspace.CurrentTab](ScriptWorkspaceCurrentTab.md)
- [ScriptWorkspace.ScriptText](ScriptWorkspaceScriptText.md)
- [Text.AppendTextFile](TextAppendTextFile.md)
- [Text.WriteTextFile](TextWriteTextFile.md)

### Example Databases

- [HotKeys](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/HotKeys.shtml#5ScriptAnchor_)
- [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

- [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)
- [Data Viewer extensions](https://www.mbsplugins.de/archive/2023-01-11/Data_Viewer_extensions/monkeybreadsoftware_blog_filemaker)
- [Formatting and error checking expressions in FileMaker](https://www.mbsplugins.de/archive/2019-12-06/Formatting_and_error_checking_/monkeybreadsoftware_blog_filemaker)
- [Insert snippet for FileMaker on Windows](https://www.mbsplugins.de/archive/2019-11-20/Insert_snippet_for_FileMaker_o/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)
- [MBS FileMaker Plugin, version 6.1pr5](https://www.mbsplugins.de/archive/2016-03-06/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [Evaluate vs. Script Trigger](https://www.mbsplugins.de/archive/2016-03-04/Evaluate_vs_Script_Trigger/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

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

This function is free to use.

Created 4th March 2016 , last changed 8th November 2024

  
[HotKey.SetEnabled](HotKeySetEnabled.md) - [HotKey.SetFileMakerWindowOnly](HotKeySetFileMakerWindowOnly.md)

[HTML Version](HotKeySetEvaluate.shtml)