Hey guys.
have a small question, ive been playing around with Script Editor making different stuff, but it gets annoying having to open each one that i want to run.
so, i was wondering, how can u make the Buttons in Xcode Linked to Applescripts.
eventually i would want to make ONE Xcode project to have a choice to open say, 5 different Apple scripts.
plz help :X
In IB you would place a button on the main window, from the “cocoa controls panel”, select a button then “key stroke command 8”, name the button “SCRIPT1”, in the event handlers section click on Action, clicked, and script, then repeat this process for your other buttons., naming them as shown in the script supplied (or how ever you wish).
In the script ive cobbled up, all you will need to do is get the path for each of your scripts and replace “path to script 1” etc with the path to your script.
Hope that helps
on clicked theObject
tell application “Finder”
if the name of theObject is “SCRIPT1” then
open file “path to script 1”
else if name of theObject is “SCRIPT2” then
open file “path to script 2”
else if name of theObject is “SCRIPT3” then
open file “path to script 3”
else if name of theObject is “SCRIPT4” then
open file “path to script 4”
else if name of theObject is “SCRIPT5” then
open file “path to script 5”
else if name of theObject is “cancel” then
quit me
end if
end tell
end clicked
ok i think im begining to understand,
but when you say event handlers and Action
do you mean the following? http://i46.photobucket.com/albums/f101/milesk11/newprogrampic.jpg
its a bad pic kinda lol but, yea i dont see clicked, and script, under that :0
thanks!
In your main application window (the one you took a pic of), go to the
folder on the left hand side called “Scripts” open that and double click
on file “Script”, cut and paste the script posted before, and save.
In your main application window (the one you took a pic of), go to the
folder on the left hand side called “Resources” open that and double click
on “MainMenu.nib”, this will launch Interface Builder.
When this has launched you should have a window called “Window”
and your palettes in front of you, if not go up to the menu bar Tools/Palettes and select “Show Palettes”.
(2a) Select your “Window” (in interface builder) then the “Cocoa-Controls” from your palette, drag and drop a “Button” (NSButton) onto your window, while button is still selected, go up to the menu bar “Tools” and select “Show Inspector”, in the inspector, in the drop box called “Attributes” select “Applescript”, "where it says “Name” type “SCRIPT1”, below name in the “Event Handlers” area click on Action and Clicked, then go down to the bottom of the inspector in the “Script” area click the radio button, save, Repeat (2a) four more times, renaming each button as per the script, then where it says (in the script) “path to script 1” etc you’ll need to put the path to your file that you want to launch, save and build.