Attaching AppleScript Scripts to FileMaker Pro - File Maker

In this section you delve into the mechanics of attaching AppleScript scripts to your FileMaker Pro solution. This can be accomplished in several ways, both internally and externally to FileMaker Pro. First consider the flow of events. Does some action performed by the user within your FileMaker Pro solution trigger the AppleScript script? Or does the AppleScript script get triggered from outside FileMaker Pro, perhaps from another application or from the Finder? Lastly, does some event completely independent of the user, such as a scheduled backup or batch calculation, trigger the AppleScript script? You’ll examine each of these scenarios next.

Running AppleScript Scripts from FileMaker Pro
It is possible to attach an AppleScript script to the FileMaker Pro interface in four ways: You can create a button, which runs an AppleScript script, via ScriptMaker. You can run an AppleScript script by choosing a menu item from the Scripts menu or by pressing the keyboard shortcut, also via ScriptMaker. You can run an AppleScript script by choosing a menu item from the OSA Menu.

You can trigger an event monitored by Waves in Motion’s oAzium Events plug-in, and then execute a FileMaker script that performs the Perform Apple Script script step.

The simplest way of attaching an AppleScript script to the FileMaker Pro interface involves running an AppleScript script from a ScriptMaker command. ScriptMaker offers two commands for this purpose: Send Apple Event for external AppleScript scripts, and Perform AppleScript for internal AppleScript scripts. In the Database Publishing Example.fp5, two ScriptMaker scripts have been created to demonstrate these commands: External AppleScript and Internal AppleScript.

Send Apple Event (ScriptMaker Script Step)
Use Send Apple Event to launch an external AppleScript script or any other application. In ScriptMaker, move the Send Apple Event script step into the current script and click the Specify button to bring up the window shown on the following page:

Send Apple Event (ScriptMaker Script Step)

Click the Specify Application button to select the target AppleScript script or application to pass control over to. Only AppleScript scripts that have been saved as applications may be called in this manner. When an Apple Event is sent from FileMaker Pro, FileMaker Pro is obviously the frontmost application. The Apple Event will be sent to the target application, which will launch and run in the background. However, the user has no visual indication that the ScriptMaker command they’ve executed actually worked! And a confused user is a dangerous user. Therefore, it’s a good idea to bring the target AppleScript application to the foreground where the user can see it running as indicated by the spinning beach ball cursor.

Perform AppleScript (ScriptMaker Script Step)
Use Perform AppleScript to execute an internal (embedded) AppleScript script. In ScriptMaker, move the Perform AppleScript script step into the current script and click the Specify button to bring up the following window:

Perform AppleScript (ScriptMaker Script Step)

You can refer to an AppleScript script contained in a FileMaker Pro text or calculation field, or you can enter it in the Script text box. FileMaker Pro actually has its very own internal AppleScript runtime environment and cript interpreter. When you click the OK button in the dialog box above, FileMaker Pro performs a syntax check and will warn you of syntax errors.

However, this Script text box is not the world’s most robust editing and debugging environment. If your scripts are any more than a few lines long, you may have difficulty composing a script that passes the syntax check.

There are several advantages to executing AppleScript statements internally in a FileMaker Pro database versus sending an Apple event to an external Apple Script application: You don’t have to worry about your users deleting, renaming, or moving your external AppleScript application, and if you’re sharing your database with multiple users and want to make changes to your script, you only have to update it once.

OSA Menu (Mac OS 9 System Extension)
OSA Menu is a freeware system extension that adds an iconic scripts menu to the right side of your Mac’s menu bar and is accessible within every running application.

Its menu items are AppleScript scripts that run when selected and that generally act upon the active application. Some scripts are available to all applications; other scripts are available only to particular applications, as configured by the user or developer. You can collect your own favorite set of scripts to augment FileMaker Pro.

After it has been installed, you’ll find you’ve got a new Scripts folder within your System Folder. Inside this Scripts folder are several subfolders. Two are named Universal Scripts and Finder Scripts. Any AppleScript scripts that you place in the Finder Scripts folder will appear as menu items in the OSA Menu whenever the Finder is the active application.

Inside the Scripts folder, you can create a folder called FileMaker Pro Scripts. Any AppleScript scripts that you place within this folder will appear as menu items in the OSA Menu whenever FileMaker Pro is active and frontmost. You can run these scripts without leaving FileMaker Pro. It’s even possible to assign a command key shortcut to these menu items by appending the appropriate suffix to the script name. Just add a backslash (“”), followed by the singlecharacter command key you wish to use. If the shortcut is to include a modifier key, append “+S” (SHIFT), “+O” (OPTION), or “+C” (CONTROL) to the suffix. You can even employ several modifier keys by combining these codes: “+OS”(OPTION-SHIFT), for example.

Example: Haven’t you always lamented the lack of a keyboard shortcut to open ScriptMaker’s Define Scripts dialog box? Here’s how to assign the keystrokes COMMAND-SHIFT-S as a shortcut for this action:

In Script Editor, create a script with the following statement:

The text must be exact. Use OPTION-2 for the trademark symbol and OPTION- ; for the ellipsis.

Save this script as a compiled script or as an application with the name “Open ScriptMakerS+S” and place it into the FileMaker Pro Scripts folder inside the Scripts folder inside your System Folder.

That’s it! Launch FileMaker Pro and type COMMAND-SHIFT-s. ScriptMaker’s Define Scripts dialog box should appear.


In FileMaker Pro, the scripts found under the Scripts menu may vary from database to database. This can be good and bad for the user and the developer. It often amounts to extra work for the developer to support the same script in every database. But that’s just the way it is. Not so with OSA Menu. Once you’ve placed a script in the FileMaker Pro Scripts folder, it’s available to all databases whenever FileMaker Pro is running, but only on the computers where this script has been installed.

So, what’s remarkable about the Open ScriptMaker script from the OSA Menu is that it’s not database dependent. It’s not part of the solution you give to your users (unless you want it to be), and it runs on any FileMaker Pro database on your machine without having to be explicitly created or imported into each database.

Script Menu (Mac OS X Component)

Script Menu provides a suite of useful system level and application-level scripts, and allows the user to add additional scripts to a custom Scripts folder, located within the user’s home directory at ~/Library/Scripts/. Inside this folder, you can create a folder called FileMaker Pro Scripts. All of the sample scripts you learned about in the previous section (OSA Menu) can be placed in this folder, and they will work in the same manner. Script Menu differs from OSA Menu in two important respects:

Script Menu does not support command-key shortcuts.

Script Menu allows access to all submenus at all times, whereas OSA Menu would only make a submenu appear if it was relevant to the frontmost application.

Like OSA Menu, Script Menu is a wonderful utility for providing FileMaker Pro users and developers with a suite of powerful, reusable, database-independent scripts.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

File Maker Topics