Run Script as App Without Menu Bar?

Hello DJ!

How do you do that, care to share? :smiley:

In the info.plist you should contain

Or when you have a property list editor you should add ‘Application is Agent (UIElement)’ field and check it. Now your application is allowed to display a dialog by itself (user interaction allowed).

Good!

But is there any way I can get my script into the menubar, or, how do I define such an item? :slight_smile:

I have suspicion about defining a folder structure somewhere, may give me a menu at the menubar.
And that! Would be nice! :smiley:

Not with pure AppleScript, unless you mean the script menu.
You need Xcode with AppleScriptObjC or ObjC

I see!

But is there any way I can just make a menu appear by a folder structure put somewhere?

I’m on a lion machine again and did the following:

  • Open script editor
  • Open new template cocoa applescript

The Code:

--create a menu item
set myMenuItem to current application's class "NSMenuItem"'s alloc()'s init()
tell myMenuItem to setTitle_("Hello World")
tell myMenuItem to setTarget_(me)
tell myMenuItem to setAction_("helloWorld:")
--create a menu
set myMenu to current application's class "NSMenu"'s alloc()'s init()
tell myMenu to addItem_(myMenuItem)
set myBar to current application's class "NSStatusBar"'s systemStatusBar()

--add the menu to the system's status bar
set theItem to myBar's statusItemWithLength_(current application's NSVariableStatusItemLength)
tell theItem to setTitle_("MyMenu")
tell theItem to setHighlightMode_(true)
tell theItem to setMenu_(myMenu)

--actions
on helloWorld_(info)
	display dialog "Hello World!"
end helloWorld_
  • Now save the script as an application and check stay-open and other options off
  • Open the info.plist file inside the application bundle and add the following:

Now double click your application and you see that an menu appears next to the clock, Click the menu item in it and you’ll see a dialog appear.

I know this should be posted in AppleScript-ObjC but I want to show McUsr that it is possible with script editor only.

:slight_smile:

Hmmm.that looks interesting! …I think I’ll start hanging in the AsObj-C section :smiley:

I actually used DatabaseEvents in combination with an AppleScript Studio app a while ago. It is about time to tinker with AsObj!

:frowning: I must upgrade from SL it seems!

That depends. The ability to save Cocoa-AS apps from AppleScript Editor was introduced in 10.7, but you can also do it in 10.6 (it’s a bit fiddly – you have to manually edit an existing Cocoa-As app).

Hello and thanks!

I’ll have a look into it, when I hopefully have slept :slight_smile:

Hello!

Do any of you have a linke to a post describing how to fiddle with it in ASEditor to make it work, the whole process preferably, or the parts from different posts, I have searched, but nothing turns up by reading the headings, and I don’t have the time to do all that reading right now.

Thanks

A normal AS applet has the script saved as main.scpt in /Contents/Resources/Scripts. The Cocoa-AS apps save your script in the same place, but they also have a script called CocoaAppletAppDelegate.scpt in /Contents/Resources/. If you open the latter, you’ll see that is standard ASObjC script that loads the second script and calls run/open/reopen/quit as on it as required.

If you don’t have Lion I won’t suggest you use Script Editor at all. Use Shane’s AppleScriptObjC Explorer 2 editor which makes everything a lot easier. You can run and edit like normal script editor but also (if you pay a small amount) export to an Application.

EDIT: Another reason not to use SL’s SE is that you can’t use ‘class “”’ command.

Just to clarify: it’s free to try for 30 days (well, actually, longer…), during which there are no limitations. I’ll spare everyone the sales pitch on why it’s so much better :slight_smile:

Hello!

Thanks a whole lot!

I really don’t mind trying new things. Nor to pay for programming tools that I find useful. But it is also a question of time, and whether I’ll bite over more than I can chew. Summer is soon gone now, and the chores are coming up! :frowning:

It is also one more thing, everything I use run on batteries, I am really inclined to throw out simbl, and all scripting additions, in fact every unnecessary process, as I love the freedom the battery gives me! :smiley: But hates the charging time!

I’ll see if I can make this thing running, by making a cocoa applet with XCode, and “fiddling” it! :slight_smile:

Hello.

I recommend the DJ_Bazzie Wazzies quick and dirty system menu script in post # 12 to everybody, who’d like something to control, just a set of applications for a task. At least I sometimes find that very comfortable!

Thanks DJ! :slight_smile:

Hello.

I start out in the AppDelegate’s willFinishLaunching() with this:

tell application "Xcode"
            close project document "SystemMenu.xcodeproj"
        end tell

I have this installed as a menu item in the sam willFinishLaunching:

set myEditItem to current application's class "NSMenuItem"'s alloc()'s init()
        tell myEditItem to setTitle_("Edit")
        tell myEditItem to setTarget_(me)
        tell myEditItem to setAction_("editMe:")

And here is the editMe handler:

on editMe_(info)
        tell application "Xcode"
            open ((path to documents folder as text) & "Prj:SystemMenu:SystemMenu.xcodeproj")
        end tell
    end editMe_

As a last action under the target of the menu I have a run script action like this:

osascript -e "tell application \"SystemMenu\" to quit" cp -r /usr/local/XCodeBuilds/Release/SystemMenu.app ~/Applications open -a ~/Applications/SystemMenu.app
Your setting may vary, but if you get the idea that I now have a nifty editable menu, that I can customize for a project in a whiff, then you are quiet right! :slight_smile:

Hello.

Thank you, but that wasn’t the problem, the problem is that the darn thing needs to be started from XCode to work. Which suits me fine, (and maybe others that uses XCode as well), but for others it may be a tad impractical. :slight_smile:

Edit

I’m sorry Tom_X I didn’t read your answer as a response to the OP.

You may get one (PrefSetter) in my public box :

https://www.box.com/s/c8v9rn0o73hwg9nzmobc

KOENIG Yvan (VALLAURIS, France) mardi 11 juin 2013 15:54:24

Thanks, Yvan. Unfortunately it seems a bit buggy here (won’t let me close windows), and it doesn’t show data values.

There is a whole suite of scripts over at Mac Os X automation, that should be easily adaptible, they target AppleScript Editor, you can find them here.

I even think that the defaults program should work, if the app is set up with an uti/Bundle Identifier, in its propertylist up front.