Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How Can I Create A StatusBarItem In Cocoa-Applescript?

How can I create a StatusbarItem in Cocoa-Applescript, Xcode 5? I searched everywhere and I could only find the answer for Cocoa. If this isn't possible, is it possible to embed an Applescript file in a normal Cocoa app that would act like the one in normal Cocoa-Applescript apps? Thanks in advance.

MacBook Pro, OS X Mavericks (10.9)

Posted on Feb 8, 2014 7:36 PM

Reply
Question marked as Best reply

Posted on Feb 8, 2014 8:25 PM

AppleScriptObjC can access most of the Cocoa API, but pretty much any example you find will be in Objective-C, so you just need to do some conversion. A statusmenu is actually fairly easy - something basic is just a few lines of code. I have an older example project on my website that uses a statusmenu to demonstrate converting from Objective-C - it can be downloaded here.

3 replies
Question marked as Best reply

Feb 8, 2014 8:25 PM in response to Apple_For_The_Win

AppleScriptObjC can access most of the Cocoa API, but pretty much any example you find will be in Objective-C, so you just need to do some conversion. A statusmenu is actually fairly easy - something basic is just a few lines of code. I have an older example project on my website that uses a statusmenu to demonstrate converting from Objective-C - it can be downloaded here.

Feb 8, 2014 9:57 PM in response to Apple_For_The_Win

Thank you Red_Menace!


To make it easier for others to find the answer, this is a clipped (and slightly modified) code from Red_Menace's project to make a basic StatusBarItem:


    property NSImage : class "NSImage"
    property NSStatusBar : class "NSStatusBar"
    property NSStatusItem : class "NSStatusItem"
    property StatusItem : ""
    property MainMenu : missing value



        on applicationWillFinishLaunching_(aNotification)

            set StatusItem to NSStatusBar's systemStatusBar's statusItemWithLength_(current application's NSSquareStatusItemLength)
            StatusItem's setImage_(NSImage's imageNamed_("icon"))
            StatusItem's setMenu_(MainMenu)
            StatusItem's setHighlightMode_(true)

        end applicationWillFinishLaunching_

How Can I Create A StatusBarItem In Cocoa-Applescript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.