FM.RunScriptIdle
----------------

Runs a script after idle period.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [FM](component_FM.md) | [3.3](newinversion33.md) | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No | ❌ No |

MBS( "FM.RunScriptIdle"; DelaySeconds; FileName; ScriptName { ; ScriptParameter } ) 

**MBS**( **"FM.RunScriptIdle";** /\* Runs a script after idle period. \*/  
**$DelaySeconds**; /\* The Number of Seconds to wait before running the script. Moving the mouse or using keyboard will reset the counter.e.g. 10 \*/   
**$FileName**; /\* The name of the file that contains the script to be rune.g. Get(Filename) \*/   
**$ScriptName**; /\* The exact name of the script to run.  
Or the ID of the script in the current file.e.g. "TestScript" \*/   
**$ScriptParameter**) /\* Optional; The Script Parameter to pass to the script \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| DelaySeconds | The Number of Seconds to wait before running the script. Moving the mouse or using keyboard will reset the counter. | 10 |  |
| FileName | The name of the file that contains the script to be run | Get(Filename) |  |
| ScriptName | The exact name of the script to run.   Or the ID of the script in the current file. | "TestScript" |  |
| ScriptParameter | The Script Parameter to pass to the script |  | Optional |

### Result

Returns OK on success or error message on failure.

### Description

Runs a script after idle period.  
This script is called in FileMaker whenever no user activity has been for the given amount of time.  
You can also pass a text string to the Script as a Parameter. The parameter can be retrieved by using Get(ScriptParameter) in the script that plug-in is calling.  
  
see also [Schedule.StartScriptOnIdle](ScheduleStartScriptOnIdle.md), [FM.StopScriptIdle](FMStopScriptIdle.md), [FM.RunScript](FMRunScript.md), [FM.RunScriptLater](FMRunScriptLater.md) and [Schedule](component_Schedule.md) functions.  
  
Once you have the script running, you can use [Process.IsFrontMost](ProcessIsFrontMost.md) function to check if FileMaker is in the foreground or not.  
  
  
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

Start idle script:

 Set Variable \[$r ; Value:MBS ( "FM.RunScriptIdle"; 10; Get(FileName); "Trigger")\]  
### See also

- [FM.RunScript](FMRunScript.md)
- [FM.RunScriptLater](FMRunScriptLater.md)
- [FM.StopScriptIdle](FMStopScriptIdle.md)
- [Process.IsFrontMost](ProcessIsFrontMost.md)
- [Schedule.StartScriptOnIdle](ScheduleStartScriptOnIdle.md)

### Example Databases

- [Utility functions/Idle](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Idle.shtml#1ScriptAnchor_)
- [Utility functions/RunScript](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/RunScript.shtml#6ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 6.0pr6](https://www.mbsplugins.de/archive/2016-01-13/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 3.4pr2](https://www.mbsplugins.de/archive/2013-08-28/MBS_Filemaker_Plugin_version_3/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 3.3pr3](https://www.mbsplugins.de/archive/2013-06-02/MBS_Filemaker_Plugin_version_3/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 17th April 2023

  
[FM.RunScript](FMRunScript.md) - [FM.RunScriptLater](FMRunScriptLater.md)

[HTML Version](FMRunScriptIdle.shtml)