Odd FileMaker result

This script below works great as long as it is run from outside FileMaker (either from script editor, or script compiled as app.). But it seems to me it should work when used with the script step within FileMaker “Perform AppleScript”. I’ve tried several variations of the script but it still won’t work when run inside Filemaker. I made double-certain I escaped the quotes by using \ before each quote and I encased the entire script in quotes (FMP requires this). Any other FileMaker gurus out there got any ideas?


activate application "FileMaker Pro Advanced"
tell application "System Events"
     set GUIScriptingEnabled to UI elements enabled
     if GUIScriptingEnabled then
          tell application process "FileMaker Pro Advanced"
               click menu item "Save Current Find..." of menu 1 of menu item "Saved Finds" of menu 1 of menu bar item "Records" of menu bar 1
          end tell
     end if
end tell

I’m on a MacBook Pro Retina, OS 10.11.6 & using version 15 of FileMaker Pro & FileMaker Pro Advanced.

Just looking at the code, I would try using

Tell Application "FileMaker Pro Advanced" to activate

instead of the first line of your current script. If that doesn’t work, set up a short “Perform Applescript” to run your applescript that does work from the outside. Sloppy work around, but it should work.

activate application "FileMaker Pro Advanced"

and

tell application "FileMaker Pro Advanced" to activate

are synonyms for exactly the same thing.

Since at least OS X 10.10, we no monger may activate GUIScripting with the command
[format]set GUIScriptingEnabled to UI elements enabled[/format]

We have to give the app the permission to drive other ones.

It may be done in the Security & Privacy Preference Pane.
Open it,
Open the lock at the left bottom
Select the thumbnail entitled Accessibility
Click the button [+]
navigate to the AppleScript Editor and select it.
When its icon will be available in the scrolling area of the right edge of the pane, check its box.
close the pane.

After that you will be able to drive the apps with GUIScripting.

Your script will be reduced to :

activate application "FileMaker Pro Advanced"
tell application "System Events"
tell application process "FileMaker Pro Advanced"
set frontmost to true
click menu item "Save Current Find..." of menu 1 of menu item "Saved Finds" of menu 1 of menu bar item "Records" of menu bar 1
end tell
end tell

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) samedi 27 aout 2016 23:14:24