Perform AppleScript (macOS)
Sends AppleScript commands to another application.
Options
- Calculated AppleScript specifies a calculation to use as the AppleScript text.
- Native AppleScript is the text of an AppleScript (up to 30000 characters). Indenting of repeat loops and conditional statements is not supported.
Compatibility
Product | Supported |
FileMaker Pro | Yes |
FileMaker Go | No |
FileMaker WebDirect | No |
FileMaker Server | No |
FileMaker Cloud | No |
FileMaker Data API | No |
Custom Web Publishing | No |
Originated in version
6.0 or earlier
Description
You can create a calculation to generate the AppleScript commands to be sent, or you can type the commands directly into the Native AppleScript text area.
For calculated scripts and scripts stored in FileMaker Pro fields, the AppleScript commands are compiled each time the script is performed. If you type the script into the Native AppleScript text area, then FileMaker Pro compiles the script and detects any scripting or system errors. (The script is recompiled whenever it's edited.)
Notes
- Because AppleScript is a macOS feature, if you run a script containing a Perform AppleScript script step on a Windows computer, the script step is ignored. (An error code is generated, which can be captured with the Get(LastError) function.)
Tips on usage
- FileMaker Pro can use the Perform AppleScript script step to send Apple events to itself or to FileMaker Pro software running on other machines. For FileMaker Pro to receive Apple events, the user’s privilege set must have the fmextscriptaccess extended privilege enabled. See Editing extended privileges for a privilege set.
- Use Perform AppleScript to pass image data between FileMaker Pro and other applications. With AppleScript, you can pass images stored in container fields to other applications or pass images into FileMaker Pro container fields.
- Use Perform AppleScript to communicate with applets and other scriptable applications. For example, if you have created an AppleScript applet with sub-routines, you can call the handlers using the Perform AppleScript command, like this:
Perform AppleScript ["tell application "My Applet" to doMyRoutine()"]
Example 1
Opens the Documents folder of the current macOS user.
Perform AppleScript ["tell application "Finder" (*enter line break*) activate (*enter line break*) set x to path to documents folder (*enter line break*) open x (*enter line break*) end tell"]
Example 2
Sets the bounds of the Documents window to the specified size. The Documents folder must be open before this script runs.
Perform AppleScript ["tell application "Finder" to set bounds of window "Documents" to {170, 70, 1000, 600}"]
Example 3
Calculates and performs the AppleScript to install a network printer. "\" tells FileMaker Pro to recognize the symbol that follows as a character and not as a calculation operator.
Perform AppleScript ["do shell script \"lpadmin -p " & Printers::Name & " -E -v lpd://" & Printers::IP Address & " -P /Library/Printers/PPDs/Contents/Resources/" & Substitute ( Printers::Driver Name ; " " ; "\\\ " ) & ".gz -D \\\"" & Printers::Description & "\\\"\""]