Hi, I make a application which adds autosave to Logic Pro 9 and below. Written in AppleScript ObjeC It does using system events to click the save button in the file menu.
if FrontAppName is "Logic Pro" and pause is less than 1
try
log "Sending Save Command via Apple Events"
tell application "System Events" to tell process "Logic Pro"
click menu item "Save" of menu 0 of menu bar item "File" of menu bar 0
end tell
on error
log "Sending Save command via key command fallback"
tell application "System Events"
keystroke "s" using command down
end tell
For a while I’ve been running into the occasional user who gets the error in the log.
At first I thought it was an issue with the “Menu bar 0” part, and i tried adding a fallback to use other numbers of menu bar and such.
But today I noticed it seemed to be happening to people using other languages on there systems. I switched my system to german and yup, got the same error.
Is there anyway to handle this in applescript without repeating the script in loads of languages? Maby a number for the menu bar item?
Currently i have a fallback which sends a normal key command. However this can conflict with other things in Logic Pro and as such I would rather not use it.
you can retrieve the localized strings from the application bundle.
Actually the index of menu and menu bar is 1
tell application "Logic Pro"
set saveMenuItemTitle to localized string "Save"
set fileMenuTitle to localized string "File"
end tell
tell application "System Events" to tell process "Logic Pro"
click menu item saveMenuItemTitle of menu 1 of menu bar item fileMenuTitle of menu bar 1
end tell
Seems to be solved. I had sandboxed my app to try and get it into the Mac App store but Apple were not happy with me using apple events in this way so it never got in.
All I had to do was add an entitlement so that my app could talk to the Logic Pro.app.
…which I’m sure would be another reason for apple not allowing my app in the app store but oh well. Selling the old fashioned way seems to be working out well.
Seems to work under the english language now will give it a test in some other languages. Thanks Stephan! Been struggling with that for a while.