read command and bom

That is a great idea, often you’d want to move a file, or a selection up one level!

I wonder if you managed, to get the ASObj project up and running. :slight_smile:

A good day to you to.

By the way; I use this to move stuff down into a folder, or creating a folder and then move the stuff into it.

I think I got the idea to it from Tom_X

property scriptTitle : "Move and replace"
tell application "Finder"
	set theFiles to the selection as alias list
end tell
if theFiles = {} then error number -128
set theDestinationFolder to choose folder with prompt "Please select destination folder to move the file to:"

tell application "Finder"
	if (count theFiles) = 1 then
		set theFileName to name of theFile
		set thePathToCheck to theDestinationFolder & theFileName as string
		if item thePathToCheck exists then
			try
				display dialog "Are you sure you want to replace :" & theFileName & " in " & theDestinationFolder & " ?" with title scriptTitle with icon 1
			on error e number n
				if n = -128 then return
			end try
			duplicate theFile to theDestinationFolder replacing yes
		end if
	else -- list
		repeat with afile in theFiles
			set theFileName to name of afile
			set thePathToCheck to theDestinationFolder & theFileName as string
			if item thePathToCheck exists then
				try
					display dialog "Are you sure you want to replace :" & theFileName & " in " & theDestinationFolder & " ?" with title scriptTitle with icon 1
				on error e number n
					if n = -128 then return
				end try
				move afile to theDestinationFolder replacing yes
			else
				move afile to theDestinationFolder
			end if
			
		end repeat
	end if	
end tell

Hi McUsr,

I don’t think the SystemMenu app can be built on 64 bit. Something with the versions. Still looking into it.

Later,
kel

Sure it can.

I have the project opened in Xcode. I expanded everything. Can’t find anywhere to replace osascript. Also, When I try to get info, it errors with something like can’t something 64-bit something version Xcode.
Not sure what’s going on.

Shane said it works on his computer. Will try again with more sleep. :slight_smile:

I can’t find the last target! I’d better wait until I can see better tomorrow.

Do it in AppleScript Editor, in a new Cocoa-AppleScript app. No need for Xcode.

I must be missing something. Xcode projects don’t open in AppleScript Editor.

Open SystemMenuAppDelegate.applescript in ASE, and paste its contents into a new Cocoa-AppleScript app window. Delete the first three lines of code:

script SystemMenuAppDelegate
	property parent : class "NSObject"
	
	on applicationWillFinishLaunching_(aNotification)

plus the closing line of that handler, the whole applicationWillFinishLaunching_ handler, and the trailing"end script".

And if you do want to use the Xcode version for some reason, remove the Run Script build phase – it’s trying to use a hard-coded path to do an installation and run. You’ll probably need to change the build target and deployment target too.

That’s what I was thinking that I somehow downloaded something different. In tho project there is no ASObjC. I was trying to find the AppleScript code but there was none. Looking forward to making some menu items.:slight_smile:

That’s what SystemMenuAppDelegate.applescript is.

Sorry, it did have the .applescript file but it didn’t have anything with osascript. I looked through it several times.

Sorry about that.

The osascript bit is under Build Phases → Run Script. I don’t know how to replace the hard-coded build path, but all the script is doing is saving you from quitting a previous version and launching a new one. That’s not rocket science manually anyway (heretical talk, I know). And I suspect it will error if there’s no previous version running anyway…

Hello.

As Shane said It is no Rocket Science.

You’ll have to disable the build rule that starts it the first time. But run it from within XCode. it is better to just start it manually from the “Products/Release” Folder then, and replace the hard-coded build path with the build folder of the release path and not copy it anywhere else., the script below might help you find it. A way to disable the last target is of course to just copy the contents to the clipboard, delete it, and then build the target. When you have started the menu so you see it, then you add a run script action to the target, by right-clicking it, then you press “get info” again, and paste in the shell code for starting up the program and quitting the project.

script xcodeProds
    tell application "Xcode"
        tell (first project) to set posixProductFolder to product directory
        -- you can use "real path" instead if you want to reveal the "xcodeproj" file
    end tell
    
    do shell script "open " & quoted form of (posixProductFolder & "/")
end script
tell xcodeProds to run

It is smart to see to that you haven’t got any versions floating around in the debug folder as well.

Edit
A new version of the run script action contents:

osascript -e "tell application \"SystemMenu\" to quit" open -a ~/path to release/folder/SystemMenu.app
I’ll fix the post where I posted the post, during the day, and provide a more thorough readme file as well.

I wonder why I can’t seem to get it to run from outside XCode (After I copied it). That is, it is running, but not rendered on the menu. I guess there is some utility there, made for copying apps, but I haven’t found it yet. :confused:

Ok.

So I had to see how I could make this work.

The first thing I did was to rip out the run script action of the target. -It is fairly easy to run the script from the “main directory” of the project. (you select the blue file at top, then you’ll see systemMenu.app to the left.

The next thing you must do, is to choose that blue file, right click it, then choose “get info” and the go to the item that is named “Place built proucts in”, and choose the folder you store your project in.

Then there is a problem I haven’t solved yet, and that is, how do I make this work outside of XCode. -It just doesn’t start when it isn’t run from within XCode.

That is really fine with me, since the primary purpose of this, is access to Interface builder, and the stuff I need when I am in an XCode project. But it makes the usefullness lesser for others, who could have benefited, from a project/task/topic tailored menu.

If you really want to make a good looking menu with submenus then this project gotten via StefanK should be a very good starting point.

PS. The project is updated, but the only thing I have done is to change the build path, and rip out the last Build action, that ran the script that copied the app to the applications folder. That is superfluos, when you can’t run it stand-alone.

Hi,

First I tried building the project and here’s the warning:

I suppose this is what you’re saying about the error if there is no previous version running.

So, found the build phases osascript. Cut it to clipboard. Tried building the project and I get the same error as above. Rereading your posts to see what I missed doing.

Can’t wait to get this running now that I’ve had a good sleep.

Edited: do I have to change the Base SDK from 10.6 to 10.8 maybe?

Later,
kel

Select the target, then go to Build Settings and change the Base SDK to Latest OS X.

That was it (10.6 to Latest OS)! Ran it and got McUsr in menu bar!

Now do I have to insert the new script into ‘run script’ in the build phases?

New script:

Getting there.

It’s only a convenience thing, if you’re going to be rebuilding it regularly. And if you’re going to do it, it should use the correct environment variables rather than a hard-coded build path.