Applescript triggers

Hey,
I am learning Applescript at the moment and am doing several tutorials since I am new to all this.
Something I havent found information on is actions that can trigger an applescript.
Is it for example possible to have a script run when I open a new chrome window?
Or can I place a button in mail somewhere that can trigger a script?
Thanks

Regular AppleScript doesn't have any way of observing those kinds of things - the closest you can get is to do something like constantly poll the window count or some other property of an application, but that isn't much of a trigger.  Mail plugins are a bit of a voodoo art, but unless an application has some kind of plugin or user menu setup you can't just tack something onto them.
A Cocoa AppleScript can register for distributed notifications like any other Cocoa application, but again, the application in question needs to post some kind of notification in the first place (the Finder and iTunes are a couple that do, for example).  The system also provides a few workspace notifications such as application launch/quit, disk mounts, etc.
There isn't anything magical about AppleScript - in general, unless an application has provided a means for plugins, notifications, or even scripting terminology, it is fairly limited in what it can do with them.

Similar Messages

  • Applescript: file.open("r") returns empty in jsx

    Hey guys,
    i am having a bit of a scripting problem here. The big goal for me at the moment is creating a UI script to control aerender.
    To achieve getting feedback from the terminal about when an aerender process is completed, i let the terminal trigger an applescript running a jsx inside after effects (since the terminal can't run a jsx inside after effects itself).
    However, this particular script needs to eval the contents of a text file that is outputted during the render process (its just a log file put into a fixed location). No matter what i do: I can't get a proper response from the script. Here is what should happen when a render is done:
    function RenderEnd () {
    var report = new File ("Macintosh HD/Users/macname/generallog.txt");
    report.open("r");
    var reportstring = report.read();
    report.close();
    var reportendindex = reportstring.indexOf("Total Time Elapsed:");
    var reportcloseindex = reportstring.indexOf("aerender version");
    var reportendstring = reportstring.substring(reportendindex, [reportcloseindex]);
    var regex = /Finished composition/gi, result, indices = [];
    while ( (result = regex.exec(reportstring)) ) {
        indices.push(result.index);
    var ItemStringArray = new Array ();
    for(var i=0; i<indices.length; i++){
        ItemStringArray.push("Finished Item " + (i+1) + ": " + reportstring.substring(indices[i]-32, [indices[i]-2]));
    var AlertString = "Rendering done." + "\r" + reportendstring + "\r" + ItemStringArray.toString().replace(",","\r");
    alert(AlertString);
    RenderEnd ();
    Running this script by itself properly returns an alert containing a message "Rendering done." plus additional info about the render time and item completion.
    But whenever i have the following applescript triggering the above jsx script...
    set scriptfile to (POSIX file ("/Applications/Adobe After Effects CS5.5/Scripts/AERenderEndTrigger.jsx"))
    tell application "Adobe After Effects CS5.5"
      DoScriptFile scriptfile
    end tell
    ...the line report.open("r") just returns empty.
    Same goes when i place the jsx in the startup folder and just call the function RenderEnd () via applescript. It's as if the file open/read stuff does not work when using applescript.
    Does anybody have an idea about this or knows the reason for why this obviously wrong behaviour happens? Maybe someone knows a different approach of how to get feedback from a completed aerender process back into a UI script.

    Ok, i finally found the issue:
    Applescript apparently does not recognize file paths beginning with a drive designation:
    When i change the file path part of the report file from
    var report = new File ("Macintosh HD/Users/macname/generallog.txt");
    to simply
    var report = new File ("/Users/macname/generallog.txt");
    everything works as it should.
    It's still a bit weird and i don't understand this. Maybe someone can explain this to me, please?

  • Number doesn't support applescript!?!

    I was sincerely hoping that numbers supported embedded applescript or at least applescript triggers (from checkboxes, buttons, etc). Internal Applescript support was the critical requirement to use it, and replace excel.
    I was blown away that is doesn't even support applescript at all!!! Apple not even supporting their own scripting technologies?
    Bizarre.

    Can someone please help us with this? We don't know if this is a Win2K file system issue, Tomcat, or our EDK install ...
    I'm hoping someone has run across this before and can help.
    Thank you,
    Jeff Conners
    Staples, Inc.

  • Automator send unix command

    I am making a Automator script for ARD that lets me pick a computer list then run a unix command that runs softwareupdate.
    How is there a script will show the results of the command?
    I would like to have it display the updates that are need then I can have it run the command again and update the system.
    Anyone know about Automator

    You might be able to automate copying the report output to the clipboard and saving it that way, or through Automator and/or AppleScript (triggering the script through Automator), it might be possible to save the report directly, though I don't see anything obvious in the AppleScript dictionary for ARD that would make that possible. If no one else here has an idea, you might take the question up in the Automator or AppleScript forums.
    It would take a lot of AppleScript work to parse out the name of the update, though, if you want to fully automate the process rather than you just manually typing in the name of the update in the softwareupdate command.

  • Ichat script fails with lion

    Hi!
    I have an applescript triggered by going online with ichat that updates my status on my website which worked fine in snow leopard.
    What it does is send a json file to my server via ftp:
    using terms from application "iChat"
    on login finished
    do shell script "curl -u ftpuser:password -T /Users/Me/Documents/Stuff/status/online/status.js ftp://ftp.serveur.com/statut.js"
    end login finished
    end using terms from
    When I use it now it returns an error:
    Erreur : sh: c: command not found
    Any clue?
    ps: The script (curl...) works fine in terminal.
    (mantra: I love lion, I love lion, Ilove lion 100 time before going to sleep...)

    Hi,
    Yes the Leopard and Snow Leopard forums for iChat still show as "Refine this List" items (I search for terms now and then but mostly for 'iChat")
    The current Community is about where the iChat AV category (iChat 3 and iChat 2.1 & Earlier) used to be but has become one community and "lost" the iChat 2.1 and earlier forum and somewhat achieves what the regular posters wanted (One palce for iChat).
    Part of the issue is also that Users Tips under the new Software have yet to permeate to many of the regular communities.
    Add to that the fact that IMAgent is doing a  job for iChat and for FaceTime in Lion (difficult to know where to put a "Sticky"/Users Tip
    8:41 PM      Monday; February 13, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Dealing with user mistakes in the input language?

    Hi
    I unfortunately many times start typing away without realizing that the current input language isn't what I intended. On Windows, a useful utility exists (e.g. for Hebrew: http://www.freeware.co.il/hebrew/) to convert the most recently typed text into the alternate input language (English<=>Hebrew) with the stroke of a key. You can see in the page a screencast of how it works.
    I wonder if there is any software or some hack which can create for me a similar functionality for the Mac.
    If not, is there some utility that can display the icon of the current input language in a much more conspicuous way, e.g. as a large icon in the dock, or a floating window?
    Thanks!
    Guy

    I'm afraid you missed the point -
    My point was that you might find a utility to do what you wanted for Hebrew at one of the sites mentioned at the bottom of that note.
    Even some applescript, triggered through a keyboard
    shortcut, could do the trick of converting typed text
    from one language to the other.
    Yes, it should not be impossible for someone who knows how to do such things to create such a program. You would need to specify the layout used for each of the languages, because many languages have more than one mapping of keycodes to characters (e.g. US and Dvorak for English, Hebrew and Hebrew Qwerty for Hebrew).
    Unfortunately, in the 7 years I've been following language issues here, I've never seen mention of this kind of program or, until now, a request for one.

  • Create new event in iCal that triggers an applescript

    Dear applescripters
    I am trying to write a script that creates an event in applescript that launches an applescript.
    This is the code:
    tell application "iCal"
    tell calendar "Verstuur"
    set theCurrentDate to current date
    set time of theCurrentDate to (time of theCurrentDate) + 60
    set verstuur to make new event at end with properties {start date:theCurrentDate, end date:theCurrentDate + 1 * minutes}
    tell verstuur
    make new open file alarm at end with properties {trigger interval:0, filepath:POSIX path of "file://localhost/Users/jschaafsma/Desktop/Verstuurfilmpje"}
    end tell
    end tell
    end tell
    when iCal tries to trigger the script iCal generates an error that the file Verstuurfilmpje is not found.
    Any ideas what i am doing wrong?
    Thanks
    Jschaafsma

    Well, for one, your file path isn't valid.
    … filepath:POSIX path of "file://localhost/Users/jschaafsma/Desktop/Verstuurfilmpje"}
    First off, POSIX path of takes a Mac-style (i.e. colon-delimited) path or alias and converts it to an POSIX path, so either you need to drop the 'POSIX path of' code, or pass in a Mac-style path.
    Secondly, even if you were to use 'POSIX path of', your path specification is invalid anyway - you haven't passed in a POSIX path you've passed in a file URL, which is different. A POSIX path of that file would look like:
    filepath: "/Users/jschaafsma/Desktop/Verstuurfilmpje"
    So rewrite this line and you should be set.

  • Calendar triggered sending of emails via AppleScript / AutoMator

    Let us say that I have groups defined in my Contacts app.
    I want an AppleScript / Automator workflow that will send a predefined text (with placeholders for first name) a predefined number of hours (say 12 hours) before a calendar event / date (say Thanksgiving) one by one to each person in a specified group.
    I guess I could spend a few hours building this, but it sounds like something someone must have done before.
    Any pointers?
    Thanks.

    Sorted it. I need to change addRecipient to setRecipient.

  • Play iTunes soundtrack under Keynote with Applescript

    OK, so this isn't a question, more of a solution to a question I was struggling with: how to play multiple songs in the background of a Keynote presentation. What's more, I needed that soundtrack to fade out for certain important slides that had their own audio, but then fade back in (without starting over) when that slide was done.
    I'm creating a standalone presentatoin that will run unattended, looped, during an event. It must be completely automated. It's mostly text slides, which is why I wanted general music underneath. But there are also some slides with videos of their own. I wanted a way to drop the soundtrack at the right time, and then restore the soundtrack afterward.
    My solution is to set up my playlist in iTunes, play it, then run an applescript, and then start the slideshow. The script first sets the iTunes volume to whatever "MAX" volume is in the script. You can edit this to be a MAX volume of 10, 40, 100, etc. The script constantly monitors the slideshow, and when the slideshow gets to any slide with the command "itunesdown" anyhwere in the text of the presenter notes, it triggers an incremental drop of iTunes' volume by 10 units every .1 second until the volume is zero. If you want a slower fade, look for all of the delay values of .1 and make them .2, .3, whatever. It also keeps a lookout for any slide with the text "itunesup" and does exactly the reverse, raising the volume incrementally up to the MAX value.
    I have not explored the possibility of also having the script monitor other text variables to perhaps trigger different playlists. I think that's possible, but for someone else to work out.
    I'm sure there's a more elegant way to code this; I have certain lines of code literally repeated ten times to cover the full range of volume from 0 to 100 and back. I know there's a counter function that could do that in less space. But, again, I'll leave that to y'all.
    Hope this helps someone!
    -Scott
    #ENTER YOUR OWN MAXVOL VALUE ON THE NEXT LINE
    set MAXvol to 80
    tell application "iTunes"
         if it is running then
              set the sound volume to MAXvol
         end if
    end tell
    repeat
      #LOOK FOR VOLUME DOWN SLIDE
         tell application "Keynote"
              set slideNotes to get notes of current slide of first slideshow
              if text of slideNotes contains "itunesdown" then
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
      #Decrease iTunes Volume
                   tell application "iTunes"
                        if it is running then
                             set curVol to the sound volume
                             if curVol > 10 then
                                  set sound volume to curVol - 10
                             else
                                  set sound volume to 0
                             end if
                        end if
                        delay 0.1
                   end tell
              else
      #LOOK FOR VOLUME UP SLIDE
                   if text of slideNotes contains "itunesup" then
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
      #Increase iTunes Volume
                        tell application "iTunes"
                             if it is running then
                                  set curVol to the sound volume
                                  if curVol < MAXvol then
                                       set sound volume to curVol + 10
                                  else
                                       set sound volume to MAXvol
                                  end if
                             end if
                             delay 0.1
                        end tell
                   end if
              end if
         end tell
    end repeat

    Oh - I forgot to cite my work. Thanks to these sites for the inspiration and some of the code
    http://alxndrmlr.biz/2011/06/itunes-increase-decrease-volume-script/
    http://stackoverflow.com/questions/8710892/applescript-detect-what-slide-is-show ing-in-keynote

  • Error in applescript to fix dates with GMT shift

    Hello,
    I am attempting to fix a problem with importing OFX files from the bank's website. Therein, dates are stored this way:
    <DTPOSTED>20110106000000[+9.0:JST]
    The time zone indicator causes Numbers to incorrectly compensate dates, resulting in one day earlier than the correct date to be displayed. Removing [+9.0:JST] fixes the problem, but that is tedious to fix many entries. Thus I thought to write an applescript to fix this issue.
    This is the script I wrote:
    tell application "Numbers"
    tell document 1
    set currentSheet to 0
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of (tables whose selection range is not missing value)
    end tell
    if x is not 0 then
    set the currentSheet to i
    exit repeat
    end if
    end repeat
    tell sheet currentSheet
    set the currentTable to the first table whose selection range is not missing value
    tell the currentTable
    repeat with theCell in every cell in selection range
    set theValue to value of theCell
    set theNewValue to ((theValue) + (time to GMT)) as date
    set value of cell theCell to ((date string of theNewValue) as date)
    end repeat
    end tell
    end tell
    end tell
    end tell
    However this error occurs:
    error "Can’t make "2011.1.09" into type date." number -1700 from "2011.1.09" to date
    It appears there are problems with how Numbers 2009 deals with date formats, but I have not been able to understand how to make this work.
    The English discussions forum seems more active than the Japanese, so I am asking here hoping someone can help. Thank you in advance.

    Hello Hiroto
    (1) Best wishes fro the new year my friend
    (2)
    To get your script running I had to edit it this way :
    For Numbers '09, which has specific defect in getting date value from cell by AppleScript.
    tell application "Numbers"
    tell document 1
    -- omitted (same as the original)
    tell sheet 1 --currentSheet
    -- omitted (same as the original)
    tell table 1 --currentTable
    repeat with theCell in (get every cell of selection range)
    set theCell to theCell's contents
    set value of theCell to (((value of theCell) + (my get_diff2UTC())) as string) -- [2]
    end repeat
    end tell
    end tell
    end tell
    end tell
    [1] Due to Numbers' AppleScript's defect, when getting date value of cell by AppleScript,
    the retrieved date is in local time calculated as follows :
    <retieved date value> = <stored date value> + <time to UTC>
    [2] When setting date value of cell by AppleScript, the stored value is the same as the source value.
    on get_diff2UTC()
    return -(time to GMT)
    end get_diff2UTC
    The handler is due to a Snow Leopard new feature
    When we trigger a command belonging to an other sdef than the one of the application owning the block we get an error.
    Some times this one doesn't hurt, sometimes it does.
    Here, calling time to GMT in the tell Numbers block generate an error which doesn't hurt but I dislike this kind of thing and decided to trigger it from the outside of the block.
    Here is the log report when triggering time to GMT from the tell Numbers block :
    tell application "Numbers"
    get every cell of selection range of table 1 of sheet 1 of document 1
    --> {cell "B2" of table "Tableau 1" of sheet "Feuille 1" of document "Sans titre"}
    time to GMT
    --> error number -10004
    end tell
    tell application "AppleScript Editor"
    time to GMT
    --> 3600
    end tell
    tell application "Numbers"
    get value of cell "B2" of table "Tableau 1" of sheet "Feuille 1" of document "Sans titre"
    --> date "vendredi 14 janvier 2011 14:52:10"
    set value of cell "B2" of table "Tableau 1" of sheet "Feuille 1" of document "Sans titre" to "vendredi 14 janvier 2011 13:52:10"
    end tell
    Now, here is the log report when I use the handler :
    tell application "Numbers"
    get every cell of selection range of table 1 of sheet 1 of document 1
    --> {cell "B2" of table "Tableau 1" of sheet "Feuille 1" of document "Sans titre"}
    end tell
    tell application "AppleScript Editor"
    time to GMT
    --> 3600
    end tell
    tell application "Numbers"
    get value of cell "B2" of table "Tableau 1" of sheet "Feuille 1" of document "Sans titre"
    --> date "vendredi 14 janvier 2011 14:52:10"
    set value of cell "B2" of table "Tableau 1" of sheet "Feuille 1" of document "Sans titre" to "vendredi 14 janvier 2011 13:52:10"
    end tell
    Yvan KOENIG (VALLAURIS, France) vendredi 14 janvier 2011 15:56:45

  • Mail.app - Applescript - Looking for help with my 1st Applescript

    Okay… so I am taking the plunge. I've finally found something that is bugging me enough that I want to make a script to resolve it.
    *Here's the situation:*
    I use Smart Mailboxes a lot. It's my primary window into dealing with email.
    I use MailTags (an addon for Mail) to apply keywords to messages, via Mail Act-On rules (an addon by the same company).
    I use Smart Mailboxes to show me messages with various keywords etc.
    What I have found is that Smart Mailboxes do NOT automatically update themselves. For instance, when a message in the Smart Mailbox is changed in such a way that the filter on that mailbox should not display it, the message will still sit there until I either leave the mailbox and return, or hit Rebuil in the Mailbox menu.
    The same applies for when new mail comes into my Inbox. If there is new mail that qualifies for inclusion in the smart mailbox I am currently viewing, it will not appear until I do one of the above two things.
    What I discovered was this script:
    tell application "Mail" to activate
    tell application "System Events"
    click menu item "Rebuild" in menu ¬
    "Mailbox" in menu bar 1 of process "Mail"
    end tell
    This is what got me thinking about scripting a solution.
    The other option is to assign a keyboard shortcut to the Rebuild command. But I would like the Rebuild to take place automatically when I apply certain rules to messages. I want my Mail Act-on rule to trigger the a Rebuild. I figure I can do this by having it trigger the Rebuild script shown above.
    *HERE IS MY QUESTION:*
    Is there a way to have the script check what the currently active/selected Mailbox is? Or, put another way, can I get it to NOT run if certain mailboxes are selected?
    Here's what I am thinking.
    Under no circumstances do I want this script to be triggered if the current mailbox is NOT a smart mailbox, and IS any of my IMAP mailboxes… most especially the Inboxes. That would trigger a complete cleaning out and rebuilding of the entire IMAP inbox, which has many gigs of mail in it.
    What I am trying to figure out, and would love some help with, is how I can make sure this script ONLY runs when the current mailbox is either ANY smart mailbox, or NOT an IMAP mailbox, or some other logic that keeps it from running in an IMAP mailbox.
    Any tips are greatly appreciated.
    With thanks,
    Jonathan
    Message was edited by: InspiredLife
    Message was edited by: InspiredLife

    Thanks Camalot,
    I appreciate your help with this. I am also enjoying learning more about AppleScript. It seems much easier that other scripting languages, if for no other reason that it uses basic english logic and words.
    When I run your script with an inbox selected, I get the following Result:
    tell application "Mail"
    get selected mailboxes of message viewer 1
    --> {mailbox "INBOX" of account "JE Gmail"}
    end tell
    Result:
    {mailbox "INBOX" of account "JE Gmail" of application "Mail"}
    When I run it with a smart mailbox selected the following is produced:
    tell application "Mail"
    get selected mailboxes of message viewer 1
    --> {current application}
    end tell
    Result:
    {application "Mail"}
    So get the impression it's not throwing up an error. Certainly, either way it does not run what I put into the On Error section, which was simply
    display dialog "Success"
    Is this useful? Can I test if the output contains the word "INBOX" ?
    I notice that if I have, for instance, a SENT folder select, it gives the following result:
    Result:
    {mailbox "INBOX/Sent Messages" of account "[email protected]" of application "Mail"}
    Which again has the word INBOX in there. Drafts comes up a little different.
    Result:
    {mailbox "Drafts ([email protected])" of application "Mail"}
    So if there was a way to parse the result through a test against "INBOX" "DRAFT" etc then this might work. What do you think?
    I have no idea how to go about that though, so your input would be very helpful.
    Thanks,
    Jonathan

  • What applescript do I use to trigger to play a video in quicktime or itunes from MainStage 3?

    I am new to Mainstage 3... I have made a karaoke video to play along with live in logic pro x and can easily play along with a full screen video there, but want a program that is processing less so less can go wrong...  I bounce the video (+10 or so tracks) to a .mov file, and would like it to play when I press play on Mainstage 3.  I would then like to play and sing with that in Mainstage 3 with 2-3 inputs live (as opposed to the 10 or so audio tracks in logic (with plugins running) and the video with 2-3 live inputs it would be cleaner and easier for my macbook pro)...
    In complete honesty I have the tracks beatmapped in logic and would like Mainstage to keep that info as well, but after I've messed with Mainstage I sadly don't think that is what Mainstage was designed for...
    Anyways I've scowered all over the internet and it appears the only way to get Mainstage to play a video is by writing some applescript that triggers a midi event that tells quicktime/itunes to play a .mov file... I have no idea why the ability is not just given to mainstage, but at least there is supposedly a work around...
    I have little experience with mainstage and no experience with applescript...
    What code do I put in the scripter to make a .mov file play a full screen (on second screen) when I press play in Mainstage 3?
    Is that even right?
    system specs-
    OS X 10.8.4
    Mainstage 3.0.1
    Logic Pro X 10.0.3
    (I don't care what player i use but these are the ones I have to work with)
    (preferred) Quicktime Player 10.2
    Itunes 11.0.5
    VLC 2.0.8
    I have messed around with the applescript editor in my utilities, and looked at some in the app store, but none of them have direct answers that I have found by google-fu-ing..
    The only other option would be to manually press play, fullscreen, then switch back to Mainstage 3... I MC and that takes a lot more time/energy/focus than simply pressing the play button in Mainstage 3 (seriously why doesn't it play videos?)...
    A lot of info, requirements, and questions I know, but when the video is not playing I would like to have my desktop showing (I put drink specials, future gigs, advertisments on a picture slideshow as the desktop on the second monitor)
    If all this works it will be epic
    Worst case I'll stick with Logic X
    Please help

    ALOT of us are attempting to do this VERY thing!
    I have searched high and low for information, even attempted using MS current scripts and modifying them.
    I have a sneaky feeling that MS scripts are somehow different than a typical Applescript.
    (changing iTunes to Quicktime)
    If anyone can pipe in here, that HAS actually accomplished this, the cheque is in the mail!!
    Treatment

  • Displaying an alert (Applescript or otherwise) from shell script?

    I have a point in a shell script where I'd like to put up an alert dialogue on a particular error condition. The script runs in the background and doesn't have a terminal window. I tried writing a little applescript that uses the applescript alert command and call it using osascript from my shell script, but it doesn't work. If I enter "osascript ~/myscript.scpt" in a terminal window, I get the error message "/Users/Ted/myscript.scpt: execution error:No user interaction allowed. (-1713)" (If I run myscript.scpt from the script editor it does what I want it to do.) Any ideas? I suppose I could have my shell script create a file in some folder and have my applescript be triggered as a folder action, but that seems pretty roundabout!

    Thanks -- I apologize for not doing a more thorough search! Yes, that comes very close to addressing my need, but I have run into one difficulty. If I run my shell script from the terminal (pasting it in) everything works fine. If I run it as a packaged app (with Platypus) everything works like it's supposed to, except that the alert applescript (it's just a one line script) briefly flashes the alert dialogue when it's supposed to and then dies, rather than waiting 10 seconds or until I click OK. I'll have to experiment and see if I can tell what's going on.

  • Applescript to automatically reply to an email

    Hi, I'm trying to create a script in Lion that will send an automatic reply to messages I receive with the subject line "Here's your offer". I am a BCC recipient of these messages, and I want to send the message to the actual recipient, not to the sender.
    I created a rule to run an Applescript if the subject is "Here's your offer" but it's not doing anything. Even if it were working, I'm sure it's missing the code to send the message to the recipient in the To: field of the triggering message. I'd love some input on this script:
    using terms from application "Mail"
              on perform mail action with messages theMessages for rule theRule
                        tell application "Mail"
                                  repeat with thisMessage in theMessages
                                            set AppleScript's text item delimiters to {""}
                                            set thisSender to sender of theMessages
                                            set theNewMessage to reply thisMessage with opening window
                                            tell theNewMessage
                                                      set content to "Test message"
                                            end tell
      send theNewMessage
                                  end repeat
                        end tell
              end perform mail action with messages
    end using terms from

    It is possible to create a new mail message using Applescript, and to send the message, or to bring up the new message window for further editing before sending. If, however, you start with the new message window (or a reply window, effectively the same thing) I don't think it is possible to have Applescript manipulate the new message, as there is no reference to it.
    Unless your "boiler plate" text is very long, I would suggest looking at TextExpander. I strted using it back when it was freeware, but it has since gone commercial, for around $30, I think. It is a keystroke monitor, and when it sees keystroke sequences which you define it automatically replaces them with (or appends to them - your choice) predefined text. I don't know how long the replacement text can be - I only use short sequences - but you can have any number of sequences. So for example I type a.k.z (dots inserted to stop it working!) and it replaces it with my initials and the html link to my elephant icon. If you go for it I would recommend giving all your sequences the same pattern - mine are all two characters followed by z, so that ordinary words don't get accidentally substituted.
    AK

  • Applescript flow disrupted in Mountain Lion

    Has anyone else had problems with AppleScript in Mountain Lion?
    I have a script with a repeat loop that looks through every sheet in a Numbers document to gather data from the pages.  Previously (in Lion and Snow Leopard) it zipped through the document taking literally only a couple seconds.  Now it crawls through, taking minutes!!!  (No exaggeration)  It still works, however, gathering all the data correctly without completely halting or crashing, it just takes an absurd amount of time.
    I was able to debug a few other scripts that stopped working completely in Mountain Lion (as it turns out due to changes in window/sheet naming), but this one still works and I can't figure out why it would slow down to a crawl.  Anything different about AppleScript with Numbers in Mountain Lion that I should know about?
    Thanks!

    Actually the main script itself doesn't involve any GUI scripting, which I avoid unless absolutely necessary, but I forgot that the keyboard shortcut that triggers it has one tiny GUI command before triggering the AppleScript, and it turns out that's where the hangup was!  I had forgotten I had it in there, and with Mountain Lion's subtle changes to the GUI names of things it got confused.  **** GUI.  I wish everything was scriptable.  Anyway, it's super fast again now that I removed the GUI command.  Thanks for reminding me!

Maybe you are looking for

  • Need to convert a 2D array into two 1D arrays to be fed into Build XY Graph

    Hi Need to convert the 2D Output of a sub vI for display on XY Graph. Help!!! I cant find an array function that takes a 2D input and un-builds to 2 * 1D arrays

  • Urgent advice needed!

    Hi, I'm not even sure this is the right place to be asking this question, as I can't quite figure out what the problem is, but I'm hoping someone else might know the answer. I've been given a DVD of some photos from a professional photographer, that

  • Function module for converting weight unit to another unit.

    What is the function module for converting weight unit to another unit. I want to convert LB to KG. Tried with fm UNIT_CONVERSION_SIMPLE. INPUT                           100 NO_TYPE_CHECK ROUND_SIGN                      X UNIT_IN                     

  • Can't install avast anti virus on my laptop, error self exstract

    Windows could not start avast! Anti virus service on local computer. Error 1075: the dependency service does not exist or has been marked for deletion. Please help me

  • How can i delete it?

    So I am selling my computer and when I open the word thing I can see that I have 400 and something documents, and I want to erase all of them. I can't seem to find them in all of my documents, only in the word app. What can I do to delete them? Pleas