Applescript Studio and Menus

I am using Applescript Studio and Leopard.
I have created an application that has menus in it. I can call the menus fine.
For example, this works:
on choose menu item theObject
if (name of theObject is "Test Menu 1") then
display dialog "You chose Test Menu 1"
end if
end choose menu item
All I want to do is have the user make a choice from the menu, and based on that choice, call an external script. I'm stumped. Any help with this?
on choose menu item theObject
if (name of theObject is "Test Menu 1") then
-- What goes here?
end if
end choose menu item

Sample code.
Note:
Four (4) menu items were added to the projects' 'File' menu, and titled 'External Script "Eins"' (Command 1), 'External Script "Zwei"' (Command 2), 'External Script "Drei"' (Command 3), and 'External Script "Vier"' (Command 4).
Four (4) script files were created ('Eins.scpt', 'Zwei.scpt', 'Drei.scpt', and 'Vier.scpt') and saved to the 'Desktop'. The 'Drei.scpt' and 'Vier.scpt' files were dragged to the projects 'Groups & Files' list into 'Resources'.
-- Code starts here --
on choose menu item theObject
-- Example of calling scripts - external to the AppleScript Studio application.
if ((name of theObject) is "externalScript01") then run script (((path to desktop from user domain) as string) & "Eins.scpt") as alias
if ((name of theObject) is "externalScript02") then run script (((path to desktop from user domain) as string) & "Zwei.scpt") as alias
-- Example of calling scripts - internal to the AppleScript Studio application.
if ((name of theObject) is "externalScript03") then run script (((path to me) as string) & "Contents:Resources:Scripts:Drei.scpt") as alias
if ((name of theObject) is "externalScript04") then run script (((path to me) as string) & "Contents:Resources:Scripts:Vier.scpt") as alias
end choose menu item
-- Code ends here --

Similar Messages

  • AppleScript Studio and Core Animation?

    Is it possible to invoke basic Core Animation events with AppleScript in AppleScript Studio? I'm assuming that Core Animation requires Objective C, but I hope I'm wrong.

    Sample code.
    Note:
    Four (4) menu items were added to the projects' 'File' menu, and titled 'External Script "Eins"' (Command 1), 'External Script "Zwei"' (Command 2), 'External Script "Drei"' (Command 3), and 'External Script "Vier"' (Command 4).
    Four (4) script files were created ('Eins.scpt', 'Zwei.scpt', 'Drei.scpt', and 'Vier.scpt') and saved to the 'Desktop'. The 'Drei.scpt' and 'Vier.scpt' files were dragged to the projects 'Groups & Files' list into 'Resources'.
    -- Code starts here --
    on choose menu item theObject
    -- Example of calling scripts - external to the AppleScript Studio application.
    if ((name of theObject) is "externalScript01") then run script (((path to desktop from user domain) as string) & "Eins.scpt") as alias
    if ((name of theObject) is "externalScript02") then run script (((path to desktop from user domain) as string) & "Zwei.scpt") as alias
    -- Example of calling scripts - internal to the AppleScript Studio application.
    if ((name of theObject) is "externalScript03") then run script (((path to me) as string) & "Contents:Resources:Scripts:Drei.scpt") as alias
    if ((name of theObject) is "externalScript04") then run script (((path to me) as string) & "Contents:Resources:Scripts:Vier.scpt") as alias
    end choose menu item
    -- Code ends here --

  • AppleScript Studio and First Responder

    I am trying to move the cursor from one text field to another based on checking the results of a field, basically to get the user to re-enter the value if my program decides the input is invalid. This is in an AppleScript Studio application under Mac OS X 10.4.11.
    As far as I can see this should be done using the 'First Responder' command, and accordingly I am trying something like the following.
    on end editing theObject
    tell window "mainWindow"
    try
    set myvariable1 to contents of text field "field1"
    on error
    log "field bad"
    end try
    if myvariable1 contains "." then
    set the first responder to text field "field1"
    log "field should not contain a fullstop"
    else
    set myvariable2 to contents of text field "field2"
    end if
    end tell
    end
    By using log commands, I can see that the branch that should call the "set the first responder" command is being executed, but the curser stubbornly refuses to move back to field1 and instead stays in field2 (the field entered after tabbing out of field1).
    Any suggestions?
    Thanks.

    Sample code.
    Note:
    Four (4) menu items were added to the projects' 'File' menu, and titled 'External Script "Eins"' (Command 1), 'External Script "Zwei"' (Command 2), 'External Script "Drei"' (Command 3), and 'External Script "Vier"' (Command 4).
    Four (4) script files were created ('Eins.scpt', 'Zwei.scpt', 'Drei.scpt', and 'Vier.scpt') and saved to the 'Desktop'. The 'Drei.scpt' and 'Vier.scpt' files were dragged to the projects 'Groups & Files' list into 'Resources'.
    -- Code starts here --
    on choose menu item theObject
    -- Example of calling scripts - external to the AppleScript Studio application.
    if ((name of theObject) is "externalScript01") then run script (((path to desktop from user domain) as string) & "Eins.scpt") as alias
    if ((name of theObject) is "externalScript02") then run script (((path to desktop from user domain) as string) & "Zwei.scpt") as alias
    -- Example of calling scripts - internal to the AppleScript Studio application.
    if ((name of theObject) is "externalScript03") then run script (((path to me) as string) & "Contents:Resources:Scripts:Drei.scpt") as alias
    if ((name of theObject) is "externalScript04") then run script (((path to me) as string) & "Contents:Resources:Scripts:Vier.scpt") as alias
    end choose menu item
    -- Code ends here --

  • Applescript Studio - Dynamically named button title

    Can anyone tell me if it is possible to retrieve the title of a button in an Applescript Studio application?
    I have no problem if the title of the button is set in the Attributes Inspector.
    EXAMPLE:
    If I set the title of a button to "test" in the attributes inspector and attach a script to a button like:
    *display dialog (get title of button "btnName" of window 1)*
    the result will be a dialog containing the text "test"
    However, if I set the title of a button through a script like
    *set title of button "btnName" of window 1 to "test"*
    and then try to retrieve it the same way
    *display dialog (get title of button "btnName" of window 1)*
    the dialog is empty
    Does anyone know if it is possible to retrieve these dynamically set button titles?

    The name of the button has an applescript name, which is how I reference it from the script. But, the actual project uses a series of buttons which all have their titles set dynamically from a script. Also the mode of the buttons are set to "On Off" (not that I think that should make a difference) I am running leopard 10.5 with xcode 3.0.
    I'm rather new to Applescript Studio and xcode. I don't know what would be wrong with the set-up. And why I would have no problem setting the button titles from a script but not be able to retrieve them.
    I have come up with a work around, keeping track of the button titles in a separate array. I seems stupid to have to do that rather than access the existing button property, but it does work.
    I will have to set up a simple test to explore what may be going wrong.

  • Applescript Studio: Lion

    Before you tell me, I realize that Applescript Studio is not longer supported in xcode 4.0 (which *****).   But I was wondering if it would be possible to download an earlier version of xcode, that still has applescript studio, and if that would work.  That would be really great if that is possible.
    Alternatively, if anyone has any alternatives to Applescript Studio that would also be nice.  I know that ASOC (applescript objc) is an alternative, but from what I've seen, it looks really different from applescript. 
    Thanks in advanced, Boboonski

    Xcode 3.2.6 (some people still prefer it) can be installed on Lion with a little trickery - a Google search comes up with several solutions.  AppleScriptObjC is way superior to AppleScript Studio though, with the main difference being in the way that Cocoa is used.  Figuring out the appropriate Cocoa classes and methods is the biggest pain in either one, but the AppleScript parts are still AppleScript.

  • Handling of bundle in Applescript studio

    Hi,
    I'm creating an action for Automator using Applescript, Applescript Studio and command line.
    One of the command line I'm using is a perl script that I want to embeb into the .action bundle. I added it in XCode into the script folder, while when compile it appear in the Ressources folder.
    The Automator giude from Apple suggest to use in Cocoa the [self bundle] command, but I cannot find a way of doing similarly from Applescript.
    I've ben searching most of the day for a solution to get the path of the perlscript.command into the bundle of my action, but I always get message error back.
    Any idea?
    Thanks

    Hi just found my mistake.
    My code is:
    set bundleID to call method "bundleWithIdentifier:" of class "NSBundle" with parameter "mysoftware ID"
    tell bundleID
    set temp to (path for bundleID resource "ressource" extension "perl") as text
    end tell
    That work.
    What was not working is that I started my tell block by "tell bundle bundleID, but there is no need for the bundle keywork there.

  • Are there any good DVD authoring programs for Mac now that Apple has discontinued DVD Studio and iDVD? I need to make DVDs that have interactive menus and such (Final Cut X and Compressor 4's DVD option is a little cheap). Any ideas?

    Are there any good DVD authoring programs for Mac now that Apple has discontinued DVD Studio and iDVD? I need to make DVDs that have interactive menus and such (Final Cut X and Compressor 4's DVD option is a little cheap and doesn't provide any kind of professional DVD authoring). Any ideas?

    This comes up a lot these days.
    Practically speaking, there are really four options for the Mac platform: Toast (<$100),  Adobe Premier Productiom ($1,600 to buy or $50/month to rent),  find a copy of Final Cut Studio from 3rd  party (+/- $1,000 new) or a boxed edition of iLife to get iDVD ($50 - $90 on Amazon new).
    The other question everyone has is how many OS versions before iDVD or FCS breaks? No one knows, but Apple has said they're no longer supporting these legacy apps. Of course, no one is mandated to upgrade to a new OS unless they buy a new computer. So if it works on a system, stay with it as long as it makes sense.
    Good luck.
    Russ

  • AppleScript Studio: status bar and panel window

    My problem is that the panel won't open, and so I don't see the progress bar.
    All I am looking for is the panel to come down, show the progress bar turning, then for the panel to go away when iCal is done adding the event. This is the entire script, but I'm not sure I have everything right in Interface builder. The Documentation for display mentioned clicking panel ended, but then further down it looked like you didn't need it.
    I'm confused.
    -- +Event.applescript
    -- +Event
    -- Created by Michael Ewald on 6/26/06.
    -- Copyright 2006 Michael Ewald. All rights reserved.
    load panel "statusPanel" from nib "statusPanel"
    on clicked theObject
    -- Get & Format form items
    set eventTitle to contents of text field "eventTitle" of window "main" as string
    set eventLocation to contents of text field "eventLocation" of window "main" as string
    set EventNotes to contents of text view "eventNotesText" of scroll view "eventNotesScroll" of window "main"
    set allDay to state of button "allDay" of window "main"
    set startDate to current date
    set startDate to content of control "startDate" of window "main"
    set endDate to content of control "endDate" of window "main"
    -- Make Event
    start progress indicator "statusBar" of window "statusPanel"
    try
    start progress indicator "statusBar" of window "statusPanel"
    display "statusPanel" attached to window "main"
    tell application "iCal"
    set theCalName to "AppleScript Test"
    set theCal to calendar theCalName
    if allDay is equal to 1 then
    make new event at end of calendar theCalName with properties {summary:eventTitle, location:eventLocation, allday event:true, description:EventNotes}
    else if allDay is equal to 0 then
    make new event at end of calendar theCalName with properties {summary:eventTitle, location:eventLocation, start date:startDate, end date:endDate, description:EventNotes}
    end if
    end tell
    -- reset form
    set the contents of text field "eventTitle" of window "main" to ""
    set the contents of text field "eventLocation" of window "main" to ""
    set contents of text view "eventNotesText" of scroll view "eventNotesScroll" of window "main" to ""
    set state of button "allDay" of window "main" to 0
    set currentDate to current date
    set currentDatePlus to (current date) + 1 * hours
    -- Update Times
    set content of control "startDate" of window "main" to currentDate
    set content of control "endDate" of window "main" to currentDatePlus
    on error
    display alert "There was a problem!"
    end try
    close panel "statusPanel"
    end clicked
    ----

    Thanks for the response,
    right now the window is in a seperate nib file. I was
    trying to follow the applescript studio example
    "Display Panel"
    Then you need to load it, look at the example, you see panelWIndow is declared as property:
    property panelWIndow : missing value
    then inside on click handler:
    if panelWIndow is equal to missing value then
    load nib "statusPanel" -- if your nib is statusPanel.nib
    set panelWIndow to window "statusPanel" --> that's AppleScript window name
    end if
    then you can use:
    display panel panelWIndow attached to window "main"
    What is the advantage / disadvantage of having more
    than one nib file?
    Not a whole lot in simple app, because you have to load it to use it.
    But in more complex apps, the advantage is that you don't commit run time memory, if the users don't use it.

  • Applescript studio app and plist???

    Hi everyone!
    If I have an Applescript studio app and I don't write anything to a plist is it still possible the app will make it's own plist for any reason? Seems to be but I can't tell for sure because seems not to be consistent. Any help would be great!
    Thanks,
    Reg

    On second thought, the plist file might be created if
    you display something. I just did a clean install so
    everything's new. Let me check with one of the apps
    that displays a an open dialog or something.
    Yes there are certain things in AS Studio that will write to a plist file. One example I know of is if you give any of your windows an "Auto Save Name" (in the "Attribute" pane of IB's inspector pane). The "Auto Save Name" will be used as the key to a plist entry that auto-saves the window's size and position on screen. When you re-run your app the window will be opened with the size and location stored in the plist.
    I believe kel may also be correct that if your app displays an open or save dialog then some state information about those dialogs will be saved to your plist.
    You can always use "plutil" to convert the plist file from binary to xml and then display the contents to see what's in there...
    <pre>
    plutil -convert xml1 /path/to/file.plist
    cat /path/to/file.plist
    </pre>
    Steve

  • Applescript Studio Beginner - Run a script and display a window

    Hi,
    I am new to applescript studio ; I found out how to make an application displaying a window with a progress bar.
    How can I start running a script without displaying any window, and at some time in the script, run the "awake from nib" handler that will call the display of the progress bar ?
    Thanks,
    Nicolas

    Nicolas Silvestre wrote:
    How can I start running a script without displaying any window, and at some time in the script, run the "awake from nib" handler that will call the display of the progress bar ?
    The "awake from nib" handler is called automatically when your nib file gets loaded, you don't call it yourself. I suppose you could go thru the pain of putting your window into a separate nib file and then have your script load the nib file when you're ready... but that's not the easiest way to do it and you probably don't need to do this for your situation.
    All you really need to do is go into Interface Builder, select your window object and uncheck the checkbox in the "Window Attributes" pane that says "Visible At Launch". The "awake from nib" will still be called at it's normal time and your window will be loaded but it will not be displayed.
    Then you can do whatever other scripting you need to do... and when you're ready to display your window you simply call:
    show window "yourWindowsAppleScriptName"
    You can do your initial scripting at the beginning of "awake from nib" and then call "show window" at the tail end of "awake from nib" if that works for you. But you don't have to have the "show window" call in your "awake from nib"... you can call it later on in some other handler if you need to.
    Steve

  • Create a tab view item in obj-c for use in applescript studio

    I'm making an application with applescript studio. I want to be able to add tab view items to a tab view at the press of a button. The problem I have is applescript studio doesn't allow me to create a new tab view item. So I'm thinking I can create the tab view item using objective-c, pass that to my applescript, then add it to my tab view.
    In applescript I plan to use the following call methods to first create the tab view item object, and then add it to my tab view. The objective-c code which is called from the first line in the applescript code is below that. When I run my code I'm getting an error saying newTVI is not defined... so maybe you can see my error! Be kind to me because I'm new to objective-c and I'm sure that's where my problem lies. Anyway, I'd appreciate any help.
    ==Applescript calls to create and add a new tab view item
    set newTVI to call method "returnNewTabViewItem" of class "makeNewTabViewItem"
    call method "addTabViewItem:" of objMainTV with parameter newTVI
    ==Objective-c code to create the tab view item
    ==makeNewTabViewItem.h==
    #import <Cocoa/Cocoa.h>
    @interface makeNewTabViewItem : NSTabViewItem
    NSTabViewItem *newTVI;
    -(NSTabViewItem *)returnNewTabViewItem;
    @end
    == makeNewTabViewItem.m==
    #import "makeNewTabViewItem.h"
    @implementation makeNewTabViewItem
    -(NSTabViewItem *)returnNewTabViewItem
    newTVI = [[[NSTabViewItem alloc] initWithIdentifier:nil] autorelease];
    return newTVI;
    @end

    Please, any ideas?

  • AppleScript Studio/Xcode problem - Problem with text entries! Please help!

    Hey, I've been up for hours each night looking for solutions to this but still have had no luck.
    I am creating an app in Xcode/Applescript studio that will ask you to enter how many times you would like system events to repeat a certain keystroke. First of all, the code would look something like this:
    on click theObject
    If the name of theObject is equal to "myApplication" then
    (Right here would be where the variables representing text in an input in the app's window would be, which I have absolutely no clue what to type.)
    tell application "text edit"
    activate
    tell application "system events"
    keystroke x (x representing a variable)
    end tell
    end tell
    end clicked
    and that's about as far as I can get. I want a variable representing the text in the main text entry box, but I have no clue how to access that text, or even know if it's submitted or detected when I hit a button. Hopefully you're following, as I am way to confused to fully explain it, but please try and help me out if you can.

    Hi Kamprath445,
    Though this mentions iTunes, I think it has good examples you can use...
    http://dougscripts.com/itunes/itinfo/keycodes.php
    More in depth...
    http://developer.apple.com/documentation/applescript/conceptual/applescriptlangg uide/conceptual/ASLR_variables.html

  • Where do I find Applescript studio download at

    I cant seem to find a download sight for Applescript Studio does any body know of a sight where I can download it?

    Can you please send a direct link to the Xtools download and also once it is downloaded how do I use it to make a menu?
    No. I can't do that. You have to register on http://developer.apple.com/ to get the tools (it's a free registration). Once you're in, though (click the ADC Member Site link at the top), just click the Downloads link, then Developer Tools.
    As for the 'make a menu' question, that's covered at length in the developer documentation available through the same site.

  • How can I use AppleScript Studio to display an image

    How can I use AppleScript Studio to display an image in a dialog?

    Add an image well to your window in Interface Builder.
    You can also add an image file to the Resources group of your Xcode project and then set the image to be displayed inside the image well directly in Interface Builder. No AppleScript code is needed if the image is contained within your app bundle and can be set ahead of time like this.
    If the image is contained in your app's bundle but you need to set or change the image at run time then you can use a line of AppleScript to load it into the image well using just it's filename:
    set image of image view "yourImageView" of window "yourWindow" to load image "YourImageFile.jpg"
    If you need to load an image from an arbitrary location outside your app's bundle then use a path to the image file...
    set image of image view "yourImageView" of window "yourWindow" to load image "/path/to/YourImageFile.jpg"
    Steve

  • Starting an applescript studio app

    I have written an applescript. I want to incorporate it into an applescript studio app........mainly to make use of the progress bar indicator. How do I get the script to start without having to click on any buttons. Thanks.

    Hook up your window (or the progress indicator) to the "awake from nib" handler in Interface Builder and insert your existing applescript code into the "on awake from nib theObject" handler that gets created in the AS Studio script.
    Steve

Maybe you are looking for

  • Anyone knows how to implement Decomposition Tree in Oracle BI products? to

    Hello Everybody Recently I'm trying to use Oracle BIEE plus to upgrade our old report service in our product. I'm a newbee to OracleBI products but I have a question that oracle support guys in our region also could figure out a clear answer. If anyb

  • Camera roll not reducing size after deleting photos

    My camera roll stays the same size even after deleting 600 photos - I'm trying to still keep the roll included in my iCloud backup but had to size it down because the backups were too large and stopped without upgrading my storage. Why is this happen

  • Batch Rename Sequence Letter Doesn't Start with A

    I'm using Adobe Bridge CS3 to rename files. Several of the files require me to use the SEQUENCE LETTER function under BATCH RENAME. However, the names of the files contain a sequence of letters that start in the MIDDLE of the ALPHABET (i.e.  C, D, E,

  • HT4628 How do I get my mac to always show the join a network window with unsaved networks?

    Everytime I want to join a wifi hotspot or network where you have to sign in or buy a certain amount of network allowance, the 'Join a Network' window that used to pop up over the browser doesn't appear anymore, or if it does its so brief that I can'

  • Use CLOB & Ref Cursor

    Hi, Can some one help. I am getting string more than 32767 char so I want to use CLOB but I am unable to use in ref Cursor. CREATE OR REPLACE PROCEDURE PM.PROC_CURSOR_BTDCS (P_QUERY IN varchar2, P_batchid out Number) AS P VARCHAR2(32767); P_CURSOR_QU