Menu Bar items

In many applications, an item is added to the Apple Manu Bar right beside the date, little flag and user switching buttons. Using AppleScript, is it possible to add items to the menu bar?

What you’re looking for is a cocoa NSStatusItem, and No, they’re not directly available via applescript. They require the use of obj-c or java, and probably will not give you much flexibility to use with applescript. You could probably create a subclass in an ASStudio project and make calls to it via ‘call method’ to build and display your menu. But once you get it displayed, capturing the selections made by the user may not be possible using AS. I haven’t messed with this too much, so there may be some good workarounds for ASStudio projects, but on first look it doesn’t seem to be very AS-friendly.

There once was a really nice tutorial at cocoadevcentral about how to create a simple status item application, but it is no longer there. I do have a messy little test project I created to learn and test the concepts in that tutorial, which I could take some of the finer points from and send on to you if you’re interested. You may find it easier to contact the guys over at cocoadevcentral and just ask them to repost it or send you a copy of the old page, which would give you more thorough instructions than I could.

They do still have a tutorial on creating a ‘menu extra’, which is an unsupported subclass of nsstatusitem that requires third-party menu extra enabling software to allow them to run. You’ll have to read about it and see if it’s something that’s worth the effort. This approach was not appealing to me, and unless you’re creating a really important app that you expect to go wildly mainstream, this is probably even more of a stretch from what you want to mess with.

j

I have a demo AS Studio project call MenuApp that may be helpful. I haven’t worked on this in a while and there is some buggy code contained therein but it’s a start:

http://homepage.mac.com/jonn8/as/html/MenuApp.html

This is unsupported but it’s also free so, enjoy!

Jon

Greetings Panther-ites!

iNotify http://www.versiontracker.com/dyn/moreinfo/macosx/19517&mode=feedback&vid=All will place buttons in the menu bar and it is scriptable (at least in 10.2.8). It will also place scriptable Icons on your desktop at whatever x-y coordinates you may choose which can contain images & rollover images of the scripter’s choice. Has anyone tried it in 3.x ?

Sincerely,

Variable as the shade

(Mirrored-door PM G4, iNotify, OS/X.2.8)