Applescript and ditto

Hey all at the moment I am using this script to invoke the ditto command
I use this method because I can at least see the progress
but I would like something a bit better
like a display dialog at least that counts the amount of files and starts from 1 to what ever it is or some sort of percentage.
the bottom script does not open terminal and I would like to use the display dialog in the bottom script. is this possible.
I tried using 3rd party progress bars with no luck.
I am not very smart on coding. I only no a bit of applescript and unix.
Have been playing with xcode and interface builder but can never get the progress indicator to actually work for me.
set source to (choose folder with prompt "Select the Source folder")
set destination to (choose folder with prompt "Select the Destination folder")
set source_unix to quoted form of POSIX path of source
set destination_unix to quoted form of POSIX path of destination
tell application "Terminal"
activate
delay 2
do script ("ditto -V -rsrc " & (source_unix) & space & (destination_unix))
end tell
But.......
I rather use
set source to choose folder
set destination to choose folder
set source_unix to quoted form of POSIX path of source
set destination_unix to quoted form of POSIX path of destination
do shell script "ditto -V -rsrc " & source_unix & space & destination_unix
any help on this would be great
like I said I would like a loading bar but a display dialog giving me some indication on time -- percentage -- or file count would be great

the bottom script does not open terminal and I would like to use the display dialog in the bottom script. is this possible.
It can be done, but it takes a bit of extra work.
The issue is that when you invoke do shell script, AppleScript hands control over to the script and does not do anything else until that script returns control back to AppleScript. Therefore there's no way to display your progress dialog - AppleScript doesn't get a look-in until the script completes.
That's largely because in most cases you want your script to react to the results of the shell command and you can't do that if the command hasn't finished.
The exception to this rule is that you can tell the shell command to return control immediately to your script. This will let you run other AppleScript commands while the shell command executes in the background.
You do this by appending " > /dev/null 2>&1 &" to the end of the command. This redirects the output of the command to /dev/null and sends it to the background so that AppleScript can continue.
The trick now is in getting AppleScript to know the shell command's status.
For that the typical solution involves outputting the shell command's result to a temporary file (rather than /dev/null) which you can then read in via AppleScript. What you need now is knowing when the shell command is done which relies on another shell trick (hack?) that tells you the PID of the most recently launched command - you can use that to query if the process is still running.
So your command should end up like:
-- do your shell command:
do shell script "ditto -V -rsrc " & source_unix & space & destination_unix & " > /var/tmp/my.log 2>&1 & echo $!"
  -- 'echo $!' allows you to capture the PID of that process
set thePID to the result
try
  repeat
    -- does the PID exist?
    do shell script "ps -p" & thePID
    -- so show progress
    display dialog (do shell script "tail -1 /var/tmp/my.log") giving up after 2
  end repeat
on error
  -- we're done, so clean up
  do shell script "rm /var/tmp/my.log
end try
The revised do shell script command writes ditto's output to /var/tmp/my.log and returns the PID of that process. The repeat loop then repeatedly checks that PID's status (via ps -p). If the process is running that command succeeds so the script progresses to the 'display dialog' command where it shows you the last line of the log file (you can change this to show anything you like).
If the ps -p command fails because the process is no longer running, that trips the on error clause in the try block which cleans up the temp file.

Similar Messages

  • Need help with applescript and Xcode 4.3.2

    I'm trying to write my first application that will involve a GUI. I can code applescript using script editor with a bit of effort, but I'm want to have users input more than one piece of information in the pop up. So, I download xcode, create my first applescript cocoa project go to MainMenu.xib and add a bunch of labels, text fields and buttons. Looks fairly nice... Go to start it and... nothing (well the window pops up, but it doesn't do anything). Unfortunately, I haven't figured out how to link the window to the applescript... So, how do I...
    * Have the applescript prepopulate data in the text fields and pulldowns
    * Once the user changes the data in the fields tell the applescript
    * Tell the window to close and pass the control back to the applescript once either the cancel or submit button is pressed.
    More detailed...
    * What's an outlet and how do I use it here? Which of the 18 outlet(s) do i use for this?
    * What's a property (referenced on one of the web pages I saw around applescript and cocoa) and do I need them here?
    Looking at the documentation with xcode, there isn't a lot about xcode and applescipt. Looking at the web, the top links are a few years old. So, links to good relevent documentation would be very nice as well as direct answers to the questions
    Thanks,
    Scott

    I'm not sure why you are closing it, but the NSApplication class is what keeps track of the windows.  If you don't want to connect the window to an outlet from the interface editor, you can use something like
    set theWindow to current application's NSApplication's sharedApplication's mainWindow()
    ...and from there you can use whatever NSWindow methods, for example
    theWindow's performClose_(me)

  • Applescript and automator

    I have studyed html for 3 days and wordpress for 3 days , word , excel for 5 days, and llustrator and photoshop 13 yeas ago for 6 months.
    and still now its so hard to understand some how.
    but I am in need of understading now with the printed documents from my computer.
    and I wonder , so there are many defferent way to communicate with anyone out side of the world, right?
    like I know email , fax, facetime,
    but there are other way now I think because of the documents I found.
    and also with applescript and automator can do anything possible like even the child can click one and start conecting etc..
    I have the copy from its ,
    does anyone have time to explain me what it is?
    It's not that of teenager who doesn't want paretns to know or else,
    but I am quite serious for my situations.
    Please Help !
    Mac OS snow leopard to lion to moutain lion,,,,,
    but I don't know when it started yet.

    Using JavaScript to script System Events wouldn't be any better, since it uses the same Apple Events mechanism (how well it uses it is another topic).  To hold down a key you would need to use something that has access to the deeper system APIs, most likely using Xcode.
    And yes, your code snippet will press the arrow key 5 times (I am guessing that the missing space in key code is a typo).  You can place the cursor in a bunch of text in another application such as TextEdit, and use your script to activate it before performing the key codes to get a better idea of what is happening (trying to reposition the cursor in the Script Editor will reveal a bug with the delay command).

  • Is this possible in AppleScript and if so how ?

    I am trying to make an app that opens AppleScript and types in things.  I then want the AppleScript that the other Applescript wrote to save as an application, and rename it.  Is this possible and if so, can you give me an example?

    If I'm following what you want, the applescript editor is fully scriptable.  In fact, there are a bunch of applescript samples in /Library/Scripts/Script Editor Scripts/ that show you how to use applescript to write and compile applescript code into a new window.  Just for a quick-and-dumb example:
    set the target_string to "X-X-X"
    set the script_text to "display dialog \"" & target_string & "\" buttons {\"OK\"} default button 1" & return
    set outputPath to POSIX path of (path to desktop folder from user domain) & "test.app"
    tell application "AppleScript Editor"
              activate
              set newDoc to make new document
              tell newDoc
                        set its text to script_text
                        try
                                  check syntax
                                  compile
                        end try
                        save in outputPath as "com.apple.application"
              end tell
    end tell

  • Using Applescript and Automator to manage files and folders

    Hi all.
    I need to make a simple action via applescript and-or automator to take the file it's been applied to (via the services) create a folder around it with the same name as the file.
    So far, I've searched the web, found some solutions but none are really working.
    Here's the script I found :
    set myFolder to findFolder()
    tell application "Finder" to set myFiles to files of myFolder as alias list
    repeat with aFile in myFiles
      set bName to my baseName(aFile)
      tell application "Finder"
      set folderExists to exists folder bName of myFolder
      if not folderExists then make new folder at myFolder with properties {name:bName}
      move aFile to folder bName of myFolder
      end tell
    end repeat
    ---------------- HANDLERS ----------------
    on baseName(myFile)
      tell application "System Events" to set {fileName, fileExt} to {name, name extension} of myFile
      return text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
    end baseName
    on findFolder()
      activate application "SystemUIServer"
      -- Bug pointed out by Lauri Ranta http://www.openradar.me/9406282
      tell application "Finder"
      activate
      set mySelection to (get selection)
      if mySelection ≠ {} then
      set mySelection to first item of (get selection)
      if mySelection's class = folder then
      set currentFolder to mySelection
      else if mySelection's class = document file then
      set currentFolder to parent of mySelection
      else if mySelection's class = alias file then
      set currentFolder to original item of mySelection
      end if
      else
      set currentFolder to target of front Finder window
      end if
      end tell
      return (currentFolder as alias)
    end findFolder
    And here's a page where they explain how to use automator and the Services to do what I <allmost> want, with some adaptation.
    But it still doesn't work.
    http://hbase.net/2011/08/17/move-selected-files-into-a-new-folder-using-applescr ipt-and-automator/
    So if anybody has an idea n how I could do this ?
    It It could either be a folder action (I drag and drop the files into a folder and boom, they get their folder around them)that I would set on a folder on a network drive, or locally, it doesn't matter, or a service (right clic on the file and boom folder around it.
    So if anyone could help with this I'd be grateful...

    Hi,
    Make an Automator Service (Service receives selected "Files or Folders"  in the "Finder.app").
    Use this script in the "Run AppleScript" action:
    on run {input, parameters}
        tell application "Finder"
            repeat with aFile in input
                if class of (item aFile) is not folder then
                    set {tName, fileExt} to {name, name extension} of aFile
                    if fileExt is not missing value and fileExt is not "" then
                        set tName to text 1 thru -((count fileExt) + 2) of tName
                        tell (get container of aFile)
                            if not (exists folder tName) then make new folder at it with properties {name:tName}
                            move aFile to folder tName
                        end tell
                    end if
                end if
            end repeat
        end tell
    end run
    This script work on files with a name extension.

  • IWeb Applescript and Automator - scripts you shouldn't be without

    Applescript and automator will automate mundane manual repetative task that seem to take forever. These scripts fill in iWeb's void that makes it hard to implement advance features such one click ftp publishing, code editing, swithching domain site files, etc. Don't miss out on these scripts that will save you ton of time. These are scripts you shouldn't be without.
    Work smarter not harder with iWeb applescript, only from MacEzzy.
    -- Also check out the free downloadable iWeb templates.
    Powerbook G4 Ti   Mac OS X (10.4.4)  

    Thank you for your feedback.
    -- Article never mentions compressed or uncompressed. Traditionally tiff format is used for buttons and small images on web pages and jpeg is used for higher quality photos exemplified by iWeb.
    -- Search engine spiders or crawlers start from top of the page to the bottom of html pages. They craw for topic as well as content. This is exactly what appears from iWeb html pages for meta (meta name="Generator" content="iWeb 1.0.1")
    -- I am the first to admit I don't know everything but I don't make up information. I use iWeb on a daily bases and try new things to push the envelope. Things that I find helpful to me I make it available for other iWeb community users so that they don't go through tribulation.
    -- I put google ads and paypal donate buttons throughout the pages to test if iWeb is up for commercial challenge. I also tested how well the search and replace script worked. I have exemplified in macezzy website it is possible to use iWeb for business purpose. The script worked extremely well, it would have taken hours to insert google and paypal codes manually. Using the script it only took 10 min. I wanted to share that with other users who might wanted to do similar things. Sorry if that offend you, I will remove them.
    -- I never claimed to have created the script except the script that makes the first folder in documents folder. I did change the wording so that it is clear to users that they are switching sites(domain file). I did not create the awesome search and replace script either. I do mention that I have made the iWeb_ftpUpload automator.
    I have started macezzy site when iWeb was introduced and there wasn't much information about iWeb. I have and do try many things with iWeb and report to iWeb community users of things that I find helpful. I haven't made a dollar off the site and I have invested lot of my time because I like to see other users succeed.
    Powerbook G4 Ti   Mac OS X (10.4.4)  

  • AppleScript and MIDI comms - is that possible?

    I'm getting into AppleScript, had a lot of fun with FaceSpan - now I want to talk to my musical instruments over MIDI, how can I do that using AppleScript? It seems I need some "interface" between the AppleScript and the serial port. My latest idea is to somehow use OMS or even MIDI Manager but are these scriptable?
    I have an idea that an "interface" might be possible that has been designed just to be scriptable, maybe this item already exists?? does it?
    Basically this is the scheme:
    AppleScript ->scriptable doofer -> serial port -> midi interface
    the part I need to know about is the "scriptable doofer"
    I'm using OS7-9 with OSX I believe MidiPipe would be the answer.

    Ilonakalenik wrote:
    I want to unlock my phone from a version carrier to an at and t carrier is that possible ? And how
    If you mean Verizon, then no, you cannot

  • Rsync and ditto

    This may be a moot point in an age of time machine, but I've been reading man pages and am a bit confused on a point.
    The unix programs rsync and ditto sound similar, and the distinction between them seems to be mainly that ditto is geared toward local backup, where rsync is geared toward network use.
    Can anyone give me a firm distinction between the two, and whether either is even a good idea with time machine just sitting there waiting to be used? Just curious.
    thanks

    You're in the Time Machine forum. You'll do better in the Unix forum, under Mac OSX Technologies, at: http://discussions.apple.com/forum.jspa?forumID=735

  • Run VLC as background through Applescript, and more

    Qualifiers:
    VLC version 0.9.10
    OSX 10.4.11
    Applescript 2.1
    I am trying to set up an Applescript to run VLC in stream capture mode in the background.   I can get it to work with:
    do shell script "[path to bundle in VLC app] [stream URL] --sout=file/raw:[path to saved file].raw &> /dev/null 2>&1& echo $!"
    This opens up a VLC application window, captures, and all is fine.  Before I routed all the output at the end of the command it would capture the stream but the script would remain frozen until I quit the VLC application, hence the stuff at the end.  My script needs to keep running actively because it includes a component to periodically check the capture is still taking place (my Internet connection can be dodgy with wi-fi interference from neighbors) by monitoring the modification date of the capture file, so I have to route the output to null so the script doesn't hang.  I tried running it with just the background & and it still hung.  Oh, I am capturing the PID so I can include a kill command to stop the process later.
    I tried doing something similar with
    do script with command etc. -- (modification of end of command line so it finishes after ".raw")
    in Terminal and it worked too, though it opened up a couple of Terminal windows which had to stay open all the time and when I wanted to stop the capture I had to close the VLC Terminal window.
    Now the real issue.  I want to have a second copy of VLC running for other use while the first is doing things quietly.  I know it can be done.  Before writing my Applescript I used to have one copy of VLC in GUI mode capturing a stream and a second copy of the app in GUI for playing other media, both running happily side by side.  It also worked when I ran it from an Applescript with the first VLC channeling through Terminal output. Now when I have the first copy running via Applescript I can open the second copy but when I try to play a file VLC just plays the whole thing back in a few seconds with no output.  It seems the output channeling from the first command line invocation of VLC is also influencing the second application (?? !)  Although I have renamed the application I didn't start messing with things in the app package itself so maybe I also need to change some identifiers in plist settings or bundle names so it really is accepted as a completely different app?
    I know this is a mix of archaic OSX technologies, both Unix and Applescript, and maybe something non-Apple and VLC-specific but I spent an hour or two doing web searches for tips, and a lot of experimentation with various combinations myself and didn't get far.  I am not sure if I have explored all the possibilities with the shell command, or if I can do something to change my second VLC application so it truly stands alone, or this just won't work, or...?
    Oh, just in case somebody suggests it, using an "open" in a shell script does not have a -n flag under Tiger OS, so I can't start a new instance of the old VLC that way (and it may suffer the same problem).

    I discovered that even when I quit my script and tried running VLC normally after that it still wasn't playing things normally although repeated runs of the script go things running in the background fine.  I trashed VLC's preferences and things played normally.  I really wish I know how to get a second copy of VLC to run in complete isolation of the first, including separate preferences, since it is a nuisance to have to trash preferences to switch between uses of VLC.

  • Applescript and iCal

    Hi,
    I'm new to Applescript and have a litte problem with iCal. In my script I want to get a list of all summaries of a iCal calendar. But for some reasons I want to set all events to a variable first and get the summary of all events from this variable (and not directly from iCal). I tried it in this way:
    tell application "Calendar"
              set sumList to summary of events of calendar "Sync"   -- works fine, result is a list of all summaries
              set calList to events of calendar "Sync"                         -- works fine, result is a list of claendar events
              set sumList1 to get summary of every item of calList -- doesn't work (error 1728)
    end tell
    Any ideas why the 3rd line doesn't work?

    You can get more than one property at a time (in the same loop).  For example, the following, will give you a list of lists (with a sublist for each event which contains the summary, start date, end date, uid).  However, if you explain what you are trying to do, there may be a better way.
    tell application "Calendar"
              set calList to events of calendar "XX"
              set propList to {}
              repeat with calEvent in calList
          copy {summary, start date, end date, uid} of calEvent to end of propList
      end repeat
    end tell
    propList

  • Applescript and outlook 2011 reply email keeping original body

    Hi,
    I need help with an applescript.
    The idea is...
    I receive an email on Outlook 2011, and I can just run this applescript and it will create a response based on the original mail, with a predefined message.
    Right now it's working up to the point of creating a reply, adding the message and sending it. However, it is NOT keeping the original content of the message. that I'm replying to.
    Can someone help me with that part?
    I've tried many stuff and someone else helped me getting this one to work:
    tell application "Microsoft Outlook"
        set replyToMessage to selection
        if (replyToMessage is "") then -- nothing selected, don't continue
            log ("NOTHING SELECTED!")
            return
        end if
        set replyMessageSubj to subject of replyToMessage
        set replyMessage to reply to replyToMessage without opening window
        if has html of replyMessage then
            log ("HTML!")
            set the content of replyMessage to "<p>Working on HTML</p><br />"
        else
            log ("PLAIN TEXT!")
            set the plain text content of replyMessage to "Working on plain text"
        end if
        send replyMessage
    end tell
    Many thanks for the help.

    That's exactly what I needed to understand.
    The final one is like this in case someone else needs it:
    tell application "Microsoft Outlook"
        set replyToMessage to selection
        set mymessage to "Aqui se trapeo con jerga"
        set OldContent to content of replyToMessage
        if (replyToMessage is "") then
            log ("NOTHING SELECTED!")
            return
        end if
        set replyMessageSubj to subject of replyToMessage
        set replyMessage to reply to replyToMessage without opening window
        if has html of replyMessage then
            log ("HTML!")
            set the content of replyMessage to "Hello World<br> This is an HTML test<br><br><br><hr>" & OldContent
        else
            log ("PLAIN TEXT!")
            set the content of replyMessage to "Hello World<br> This is a plain text test <br><br><br><hr>" & OldContent
        end if
        open replyMessage
    end tell
    Many thanks for the help Llessur999!!

  • Hi, I am new to Applescript and after messing around with it have a few questions.

    Firstly, I love applescript so far and have made an alarm clock, simple get weather app and applescript app that announces the time and date. i would like to be able to use this as a jarvis like combined app where i can have all of these built into one applescript. secondly i would like a better version of my weather app to be included that can give me weather based on my location (not the location i have it set too). lastly it would also be a miracle if someone could give me a way to make a simple chat like bot that can talk back because i have tried setting up eliza (chat bot from apple) but because it uses ichat things are much more difficult for me as a novice to set up properly.  for instance type hi in a display dialog box and have the text returned open up in messages and be able to communicate with my chat bot that would have predefined responses for what i type. like if i type weather it would know to tell me the weather.  anyway ill have my codes listed below and if anyone can help with any part of this that would be fantastic and greatly appreciated. also just a note i will never sell this thing if someone helps me by giving me coding to get this idea working.  i just want it because i could greatly use having a virtual assistant and to use personally.  thanks in advance for all people who do help.
    --codes for getting date
    set {year:y, month:m, day:d} to (current date)
    y --> 2006
    m --> April
    d --> 15
    -- note that the month given above is not text unless coerced to text. "April" is a word in the AppleScript lexicon.
    -- these results can also be obtained directly, one at a time:
    month of (current date) --> April
    -- or as a list:
    {year, month, day} of (current date) --> {2006, April, 15}
    -- and finally, the day of the week can be extracted:
    weekday of date "Saturday, April 15, 2006 4:29:04 PM" --> Saturday
    say date string of (current date)
    --codes for getting time
    set currentDate to current date
    set amPM to "AM"
    set currentHour to (currentDate's hours)
    set currentMinutes to currentDate's minutes
    if (currentHour ≥ 12 and currentHour < 24) then
              set amPM to "PM"
    else
              set amPM to "AM"
    end if
    --  make minutes below 10 sound nice
    if currentMinutes < 10 then
              set currentMinutes to ("0" & currentMinutes) as text
    end if
    --  ensure 0:nn gets set to 12:nn AM
    if currentHour is equal to 0 then
              set currentHour to 12
    end if
    --  readjust for 12 hour time
    if (currentHour > 12) then
              set currentHour to (currentHour - 12)
    end if
    set currentTime to (currentHour as text) & ":" & ((currentMinutes) as text) & " " & amPM as text
    say currentTime
    --alarm with weather
    -- prompt the user for the desired wake up time
    set targetTime to the text returned of (display dialog "Enter the wake-up time:" default answer "7:00 AM")
    say "Goodnight sir…"
    -- wait until we reach the target date/time
    repeat while (current date) is less than date targetTime
      -- should be 60
      delay 2
    end repeat
    say "It is " & getTimeInHoursAndMinutes()
    on getTimeInHoursAndMinutes()
      -- Get the "hour"
              set timeStr to time string of (current date)
              set Pos to offset of ":" in timeStr
              set theHour to characters 1 thru (Pos - 1) of timeStr as string
              set timeStr to characters (Pos + 1) through end of timeStr as string
      -- Get the "minute"
              set Pos to offset of ":" in timeStr
              set theMin to characters 1 thru (Pos - 1) of timeStr as string
              set timeStr to characters (Pos + 1) through end of timeStr as string
      --Get "AM or PM"
              set Pos to offset of " " in timeStr
              set theSfx to characters (Pos + 1) through end of timeStr as string
              set theHours to hours of the (current date)
              if theHours > 18 then
                        say "good Evening"
              else if theHours > 12 then
                        say "good Afternoon"
              else if theHours > 6 then
                        say "good Morning"
              else if theHours > 0 then
                        say "good Morning"
              end if
              return (theHour & ":" & theMin & " " & theSfx) as string
    end getTimeInHoursAndMinutes
    tell application "Mail" to launch
    tell application "Calendar" to launch
    tell application "iTunes" to launch
    set CityCode to 2353736
    set t_format to "F"
    set v_format to "S"
    set a_format to "Y"
    set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode
    set file_content to (do shell script "curl " & IURL)
    --looking for the line with actual condition
    set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
    set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText
    set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1
    set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
    set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
    set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b
    if t_format is equal to "C" then
              set actual_temp to (5 / 9) * (actual_temp - 32) as integer
    end if
    set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
    set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText
    set today_min_temp to word 9 of sub_2
    set today_max_temp to word 12 of sub_2
    if t_format is equal to "C" then
              set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
              set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
    end if
    set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
    set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
    set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4
    set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
    set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5
    set tomorrow_min_temp to word 9 of sub_6
    set tomorrow_max_temp to word 12 of sub_6
    if t_format is equal to "C" then
              set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
              set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
    end if
    set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
    set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
    set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8
    if a_format is equal to "Y" then
              say "The current weather in Alpine is " & actual_temp & " degrees and " & actual_condition
    end if
    delay 4
    tell application "Mail"
              set unreadMessages to (get every message of mailbox "INBOX" of account "jarvisMail" whose read status is false)
              set numberofmessages to (count of (every message of mailbox "INBOX" of account "jarvisMail" whose read status is false))
              if (count of (every message of mailbox "INBOX" of account "jarvisMail" whose read status is false)) is 1 then
                        tell application "Mail"
                                  say "There is only " & numberofmessages & " new email"
                                  repeat with eachMessage in unreadMessages
                                            say "From! "
                                            say (get sender of eachMessage)
                                            say "Subject."
                                            say (get subject of eachMessage)
                                            set read status of eachMessage to true
                                  end repeat
                        end tell
              else if (count of (every message of mailbox "INBOX" of account "jarvisMail" whose read status is false)) is greater than 1 then
                        tell application "Mail"
                                  say "There are " & numberofmessages & " new messages"
                                  repeat with eachMessage in unreadMessages
                                            say "From! "
                                            say (get sender of eachMessage)
                                            say "Subject."
                                            say (get subject of eachMessage)
                                            set read status of eachMessage to true
                                  end repeat
                        end tell
              else
                        say "You have no new messages"
              end if
              tell application "Mail" to quit
    end tell
    delay 4
    set today to (current date)
    set today's time to 0
    set tomorrow to today + days
    set myHome to {}
    tell application "Calendar"
              set futureEvents to every event of calendar "Home" whose start date is greater than or equal to today and end date is less than or equal to tomorrow
              tell application "Calendar" to quit
    end tell
    repeat with anEvent in futureEvents
              tell application "Calendar" to set {summary:theSummary, start date:theStartDate, allday event:allDayEvent} to anEvent
              if (allDayEvent) then
                        set theTime to "At some time today"
              else
                        set {hours:Eventhour, minutes:Eventminute} to theStartDate
                        if (Eventhour > 12) then
                                  set Eventhour to Eventhour - 12
                                  set pre to "PM"
                        else
                                  set pre to "AM"
                        end if
                        if (Eventminute is 0) then set Eventminute to ""
                        set theTime to "At " & Eventhour & " " & Eventminute & " " & pre
              end if
              set the end of myHome to theTime & " you have the event… " & theSummary
    end repeat
    set numberOfHome to (count myHome)
    if (numberOfHome is less than 1) then
              say "you have no events today."
    else if (numberOfHome is equal to 1) then
              say "you have one event today"
      delay 1
              say item 1 of myHome
    else
              say "you have" & numberOfHome & " Home today"
      delay 1
              repeat with thismeeting in myHome
      say thismeeting
                        delay 0.5
              end repeat
    end if
    delay 4
    tell application "iTunes"
              play playlist "Jarvis Alarm"
              delay 900
              tell application "iTunes" to quit
    end tell
    --weather
    set weather to "curl " & quote & "http://weather.yahooapis.com/forecastrss?p=USNY0996&u=f" & quote
    set postWeather to "grep -E '(Current Conditions:|F<BR)'"
    set forecast to do shell script weather & " | " & postWeather
    say (characters 1 through -7 of paragraph 2 of forecast) as string

    4piper wrote:
     I have a HP Envy 15 Notebook PC "without" a cd/dvd drive. I bought one that plugs in which is a pain, but I am findind myself having to install updates that lasts for hours. Please, can someone help me??? I am almost ready to go back to Dell because I have had to many issues! I have spent more time on the upgrades/updates than I have actual enjoyment on this PC. And it is 13 days old.
    And getting a PC that does not have a cd player is completely, well I am not going to say it. How was I going to download the printer? Or any other software?
    Can someone please tell me if there is a one button upgrade/update that will get this done and over with?
    Thank you.
    Piper
    Hi,
    Could you tell us what Envy 15 it is, please? I mean the full model name. The new laptops don't have any DVD drives because all drivers etc can be downloaded from the internet and all bootable images don't have to be burned to DVDs but simple converted to usb drives. Tell us also what printer you have got so we can find the right drivers for you.
    Dv6-7000 /Full HD/Core i5-3360M/GF 650M/Corsair 8GB/Intel 7260AC/Samsung Pro 256GB
    Testing - HP 15-p000
    HP Touchpad provided by HP
    Currently on Debian Wheeze
    *Please, help other users with the same issue by marking your solved topics as "Accept as Solution"*

  • Sending an email via AppleScript and Dialogue Boxes

    I am trying to write a script to send an email via Mail of which the body of the message is from a dialogue box. I decided upon using Automator and AppleScript. I have, so far, the following workflow:
    1. Run Apple Script:
    set mypass to text returned of (display dialog "What are you doing?" with icon 1 buttons {"Tweet", "Cancel"} default button "Tweet" default answer "")
    2. New Mail Message.
    3. Send Outgoing Messages.
    4. Run Apple Script:
    on run {input, parameters}
    tell application "System Events" to set visible of process "Mail" to false
    return input
    end run
    I wand this workflow to allow the user to input an answer and this answer to be in the message field of the email. I can use the "Ask for Text" action in Automator but it does not allow for any control over the appearance of the dialogue box. The first script returns the result "<whatever is typed>" (ie. "Test") in the Results field below the script box, as does the "Ask for Text" action but it does not insert it into the message. Does anyone know what is going wrong here?
    I am relatively new to AppleScript which is why I am using Automator but would like any information on how this could be done entirely in AppleScript. My previous attempts at sending email using script was unsuccessful.
    My aim is to save this as an Application with a proper icon.

    see my reply to your post in the snow leopard forum.
    http://discussions.apple.com/thread.jspa?messageID=10318297&#10318297

  • Applescript and application process name on osx 10.10

    I have an application that I'm running on OSX, and I have this AppleScript that was working on 10.9, but it seems that it does not work on 10.10
    try tell application \"System Events\" to set processPath to application file of application process "My Application" return POSIX path of processPath on error errMsg return "" end try
    When I run this in the AppleScript editor, it gives me the error that "System events got an error: Can't get application process "My Application".
    I checked the Activity Monitor, and indeed, there is no process called "My Application" in there. The associated process with my application is now registered by the name "SWT". I confirmed this by killing the "SWT" process, and it killed my app.
    I tried setting the Application name to "My Application", (using Display.setAppName("My Application");) inside my code, which worked, and now I am able to see a process called "My Application" in the Activity Monitor, but the AppleScript is still not working. The new error that I'm getting now is:
    Can’t make alias \"Macintosh HD:Library:Java:JavaVirtualMachines:jdk1.7.0_71.jdk:Contents:Home:bin:java\" of application \"System Events\" into the expected type
    My question is, what has changed from 10.9 to 10.10, and why is my application registered as "SWT" process, instead of "My Application", as it was in 10.9?

    I have an iMac 2.16GHz and a MacBook 2.4GHz. Both were running 10.5.2; I have since updated the iMac to 10.5.3. I also have an old machine running OS X 10.2.8 server. (OK, laugh. But it works!) Before upgrading my iMac to 10.5, I could copy files to and from that server pretty quickly.
    Now, anything of size takes forever. I am connecting over wired ethernet (but wireless, having tried, is no better). I have a Airport Extreme router with Gigabit, and a separate Asante 8-port 10/100 switch. No matter how anything connects, a transfer of 200mb or so takes almost 30 minutes.
    I brought a friend's machine over running 10.4.11, and it transfered to the old Mac server the same 200mb file in less than 3 minutes or so. What I would expect.
    Thinking maybe the old 10.2.8 server was too old for 10.5, I subbed in another machine running 10.4.11 server. The times to it were terrible, too, from any of the 10.5 machines.
    I tried turning off IPV6, then the times went to hours to copy, so I turned it back to Auto. I have read that maybe there are other network settings (such as those changeable with a tool such as Cocktail) that could be the culprit. I have not explored that.
    This post is definitely not closed or solved!
    Pete

  • Help with Applescript and Admin Privelages

    I just started using Applestript a few months ago and I can't figure out how to give my script Admin rights. Basically, it turns on and off my internet sharing and file sharing through dialog boxes. I copied and pasted the whole code below if you want to test it, but this is the part that is giving me trouble. There are 4 lines similar to this, the actions that turn on or off the services.
    do shell script "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
    I've tried adding "with password _____" and "password_____" but neither worked. Can anyone help me make this script authenticate itself so I don't need to keep typine in my password? I could easily make a keystroke in system events to type it in but it doesn't always ask for it so I don't know how I'd make the script know when it needs to enter the password. any help is much appreciated!
    Some things to clarify: The first shell script is there to invoke the "authentication" dialog so I can sign in once I launch the app and get right into the settings. However, I'd like to make it so the script doesn't even need admin permission to run, or make it somehow have my password built in to it. Security is not an issue, its my personal computer that nobody else has access to so I really don't care if my password is written in the code. Also, if you have any tips on how to streamline the Quit/Hide/Resume dialog I'd appreciate that too. Resume is there because there's a chance I won't have to sign in again if the app does not quit, however more often than not I have to sign in anyways. Thanks again in advance, sorry this post is so long but like I said, I'm pretty new to all this so I don't know exactly what you need to be able to help me.
    The Whole Script:
    -- Variables and Authentication
    set done to "n"
    set quitapp to "no"
    display dialog "Please enter your password to allow Sharing Manager to make changes to your settings." with icon caution
    do shell script "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist" with administrator privileges
    delay 0.2
    -- Repeats
    repeat while quitapp is "no"
              repeat while done is "n"
      -- Choose Setting
                        display dialog "Choose Setting to Edit" buttons {"Internet", "File Sharing", "Exit"} default button 3
                        set the button_pressed to the button returned of the result
                        if the button_pressed is "Internet" then
      -- Commands for Internet Settings
                                  display dialog "Internet Sharing" buttons {"On", "Off", "Cancel"} default button 3
                                  set the button_pressed to the button returned of the result
                                  if the button_pressed is "On" then
                                            do shell script "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
                                  else if the button_pressed is "Off" then
                                            do shell script "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
                                  end if
                        else if the button_pressed is "File Sharing" then
      -- Commands for Sharing Settings
                                  display dialog "File Sharing" buttons {"On", "Off", "Cancel"} default button 3
                                  set the button_pressed to the button returned of the result
                                  if the button_pressed is "On" then
                                            do shell script "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist" with administrator privileges
                                  else if the button_pressed is "Off" then
                                            do shell script "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist" with administrator privileges
                                  end if
                        else
                                  set done to ""
                        end if
              end repeat
      -- Confirm Quit/Hide
              display dialog "Really quit? You will have to reenter admin info next time." buttons {"Quit", "Hide", "Resume"} default button 1
              if the button returned of the result is "Quit" then
                        set quitapp to ""
              else if the button returned of the result is "Hide" then
                        tell application "System Events"
      keystroke "h" using command down
                        end tell
              else
                        set done to "n"
                        set quitapp to "no"
              end if
    end repeat

    with respect to general improvements, a couple of points:
    If I'm reading this script correctly, it looks like you're putting up an applescript alert and leaving it hanging until it's dismissed.  This is an atypical approach (applescripts aren't really meant to hang around indefinitely waiting for a respons).  If I were doing this I would either go whole-hog and create an applescript application in XCode with a proper interface, or remove the hanging dialog and create a set of toggle scripts that I could use from the script menu.  if you really want to keep the hanging dialog, though, you can streamline it by absorbing the secondary dialogs into the main dialog.  that's like so:
    set netSharingStatus to checkService("com.apple.InternetSharing")
    set fileSharingStatus to checkService("com.apple.AppleFileServer")
    display alert "Current Settings" message "Click to change settings" buttons {"Internet " & netSharingStatus, "File Sharing " & fileSharingStatus, "Exit"} default button 3
    -- choose next action based on the button clicked and the status vairable
    on checkService(service)
              do shell script "launchctl list"
              if the result contains service then
                        return "On"
              else
                        return "Off"
              end if
    end checkService
    using handlers like the above can also streamline the rest of your script.  the following construction means you only have to write the do shell script line once, rather than the four times you currently do, and makes for much cleaner reading.
    if the button_pressed starts with "Internet" then
              toggleService("com.apple.InternetSharing", netSharingStatus)
    else if the button_pressed starts with "File Sharing" then
              toggleService("com.apple.AppleFileServer", fileSharingStatus)
    else
      --exit routine
    end if
    on toggleService(service, currentState)
              if currentState in "On" then
                        set action to "unload"
              else
                        set action to "load"
              end if
              set command to "/bin/launchctl " & action & " -w /System/Library/LaunchDaemons/" & service & ".plist"
              do shell script command user name "adminusername" password "password" with administrator privileges
    end toggleService

Maybe you are looking for

  • Can't edit text in Pages document

    Many times I have opened a Pages Word Proessing document that serves as a brochure.  Today I went in to edit some of the text and I can't get a cursor to drop anywhere in the text.  All the text boxes can't be edited. What may have happened? I am usi

  • Premiere Pro CC crashes when importing video

    Have updates drivers as suggested in other threads (including taking note that one of my cards needed the beta drivers. Have uninstalled and reinstalled which was the otyher common suggestion Any suggestions folks? system summary here: Summary       

  • ExFAT formated harddrive won't mount on Macbook Pro

    My job recently gave me a 4tb G-Tech G-Drive to access video and audio files to edit. The drive works fines on my bosses Windows computer and the drive is formatted for exFAT but it won't mount on my Macbook Pro. My OSX is 10.8.4 and the drive appear

  • Org.model table to store region

    Hi Please help me in finding the table from which I could get the Region details from org.model. Ex: Root -> LOB Service Root org. -> North America, Latin America, APJ. I need to get the list of SAP regions(North America, APJ etc)  available in the o

  • [SOLVED] xfce4-panel: Window buttons w/ Compiz

    Hi, I've successfully done the seemingly daunting task of getting Compiz to work with XFCE. Everything appears to be set up, got my keyboard shortcuts in order, etc., however I don't like how the xfce4-panel's Window Buttons behave when running with