How can you active the Script Menu Bar with AppleScript?
Solution 1:
10.13 (High Sierra) and before
If you do not want to have to go through Script Editor > Preferences > General to check the
[ ] Show Script menu in menu bar check box, then here is one way of enabling the Script Menu using AppleScript:
tell application "System Events"
if not (script menu enabled) then
tell current application
do shell script "open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'"
end tell
end if
end tell
You could just use:
do shell script "open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'"
However, since System Events has a script menu enabled
property, it makes sense to check whether or not it's enabled first. Either way though, opening the target file loads the Script Menu and checks the [√] Show Script menu in menu bar check box in: Script Editor > Preferences > General
Also, from Terminal, you could just run:
open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'
Opening the target file in any manner shown accomplishes the goal.
By the way, when the Script Menu is enabled the target plist file is:
com.apple.systemuiserver.plist
The key is a Boolean and is NSStatusItem Visible com.apple.scriptmenu
, and will also have an element in the menuExtras
Array as a String
holding the pathname of the item.
Note that the information above was gathered under macOS 10.13.5.
10.14 (Mojave) and up
The script menu has been upgraded into a full-fledged application, instead of a .menu
file. It is now located at /System/Library/CoreServices/Script Menu.app
.
To activate it on 10.14+, the terminal/shell command changes to:
open '/System/Library/CoreServices/Script Menu.app'