After you open Preferences in AppleScript Editor and go to the General tab toggle with ui scripting:
tell application "AppleScript Editor" to activate
tell application "System Events"
tell process "AppleScript Editor"
tell window "General"
tell checkbox "Show Script menu in menu bar"
click
end tell
end tell
end tell
end tell
Edited: here’s the whole thing.
tell application "AppleScript Editor" to activate
tell application "System Events"
keystroke "," using command down
tell process "AppleScript Editor"
tell window 1
tell toolbar 1
tell button "General"
click
end tell
end tell
tell checkbox "Show Script menu in menu bar"
click
end tell
end tell
end tell
keystroke "w" using command down
end tell
It might not work internationally because of the names.
Edited: oops, forgot to close the preferences window.
One more thing. AppleScript Editor is one of those apps where ‘activate’ doesn’t bring it to the front if it isn’t already running. To bring it to the front use launch or set the process to frontmost:
tell app "AppleScript Editor
launch
activate
end tell
I was thinking that at the beginning, there should be a check to see if AppleScript Editor is already running. If it was not running then the script should quit the editor.
Edited: something like this:
set was_running to application "AppleScript Editor" is running
-- then at the end
if not was_running then tell "AppleScript Editor" to quit
Darn, here’s something close, but the machine is telling me that the app does not allow assistive access. Anyway, here’s Yvan’s script with quitting the editor if it wasn’t running:
That’s ok. haoleserferdude is from Maui, so at least the local version will work. Just add the launching and quitting at the beginning and end. Until we have this sorted out.
I don’t get it. Before you could just allow assistive access in System Preferences. I think it was in Accessibility. Now there are no apps showing. What happened to allow assistive access.
set was_running to application "AppleScript Editor" is running
tell application "AppleScript Editor" to activate
tell application "System Events"
keystroke "," using command down
tell process "AppleScript Editor"
tell window 1
tell toolbar 1
tell button "General"
click
end tell
end tell
tell checkbox "Show Script menu in menu bar"
click
end tell
end tell
end tell
keystroke "w" using command down
end tell
if not was_running then tell "AppleScript Editor" to quit