Hi all, any helpful hints on the following would be really appreciated:
I’m trying to use this GUI script from the apple site to select a submenu item however it returns an error “System Events got an error: NSReceiverEvaluationScriptError: 4”
tell application "Script Editor"
activate
end tell
tell application "System Events"
tell process "Script Editor"
tell menu bar 1
tell menu bar item "Edit"
tell menu "Edit"
tell menu item "Find"
tell menu "Find"
click menu item "Find..."
end tell
end tell
end tell
end tell
end tell
end tell
end tell
(I’ve used Script Editors menu for example of hierarchy here)
All this is in aid of trying to tell a time management/billing application to log out all users (thus stopping running timers) after 30mins of the machine sitting idle.
I’m using a do shell script (found on MacScripter) to run the idle timer which seems to work OK but if anyone has a better method would love to hear it.
Thanks!
Hi, blocklevel.
Welcome to these fora. 
There are easier ways to open the “Find” dialog in Script Editor, but obviously you’re experimenting with menu items for use with your other application.
The “.” at the end of menu item names that have it is usually an ellipsis character (option-; on English-language keyboards), not three full stops.
Well spotted but using an ellipsis still returns the error???
BTW I do have “access for assistive devices” and GUI scripting enabled (these have been suggested in other posts).
I have only really skimmed the surface of applescript over the years - can menu items have a “display name” and an “actual name” - if so where would I find it in the app bundle.
Cheers
Hi,
why not
activate application "Script Editor"
tell application "System Events" to tell process "Script Editor" to keystroke "f" using command down
Thanks Stefan, as mentioned I’m only using Script Editor as an example of hierarchy that everyone can see/understand.
Sadly the app I’m really targeting doesn’t have keyboard shortcut for this menu command.
Ok, then try this
activate application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell menu bar 1
tell menu bar item 4
tell menu 1
tell menu item 16
click menu item 1 of menu 1
end tell
end tell
end tell
end tell
end tell
end tell
Thanks Stefan,
Works well, I take it dividers are included as menu_items.
Will apply to my app when I’m back at the studio tomorrow and hopefully all is well.
Cheers.