Hiding Menu Items

G’ day everyone,

I am trying to hide or “kill” the menu item in the menu bar with a script. Here is my script to make the menu item…

on awakeFromNib()
		set statusItem to current application's NSStatusBar's systemStatusBar's statusItemWithLength_(current application's NSSquareStatusItemLength)
		statusItem's setTitle_("") -- ⌘ ⁇ ✖ ⍢ ➤
		statusItem's setMenu_(statusMenu)
		statusItem's setHighlightMode_(true)
		set myBundle to current application's NSBundle's mainBundle()
		set myIcon to current application's NSImage's alloc's initWithContentsOfFile_(myBundle's pathForResource_ofType_("Menu_Icon", "png"))
		statusItem's setImage_(myIcon)
	end awakeFromNib

I’ve tried to hide a menu item through this code:

statusItem's setHidden_(true)

but I get this error:

[XYZAppDelegate hideMenuItem:]: -[NSStatusItem setHidden:]: unrecognized selector sent to instance 0x4009940c0 (error -10000)

You can’t hid a status item; you get rid of it using removeStatusItem:.

How would I use it? This is what I have so far…


You have to address it to the status bar. Something like:

tell current application's NSStatusBar's systemStatusBar to removeStatusItem_(statusItem)