ICal applescript: get current event?

I am trying to use Applescript alarms from iCal to do a couple things: first, I want it to set my away message in iChat to the event that called the alarm, and second, I was to be able to send an e-mail (really a text message) containing the event. I would settle for just being able to get the closest event to "now", but that is the last resort. Is there any way to get the ID of the event that called the applescript in the first place? Barring that, how can I get the closest event to "now"? The code I have seems to miss recurring events (I am comparing start time to now, but start time on recurring events was the first occurrence).

I am trying to use Applescript alarms from iCal to do a couple things: first, I want it to set my away message in iChat to the event that called the alarm, and second, I was to be able to send an e-mail (really a text message) containing the event. I would settle for just being able to get the closest event to "now", but that is the last resort. Is there any way to get the ID of the event that called the applescript in the first place? Barring that, how can I get the closest event to "now"? The code I have seems to miss recurring events (I am comparing start time to now, but start time on recurring events was the first occurrence).

Similar Messages

  • I recently upgraded to snow leopard and now every time i open iCal i get multiple events to update in iCal

    I recently upgraded to snow leopard and now every time i open iCal i get multiple events to update in iCal.  Except I don't know where these are coming from or why.   I've check iCal preferences and Help - can't find a way to stop this from happening automatically.  Any Clues?  Also, some of the events are already on my calendar and have been for quite some time.

    Greetings,
    What do you mean by "events to update"?  Do you mean invites to new events or changes to existing invites?
    Troubleshooting:
    1. Your profile indicates you are running 10.6.7, 10.6.8 is the current version Apple > Software update.
    2. First make an iCal backup:  Click on each calendar on the left hand side of iCal 1 at a time highlighting it's name and then going to File Export > Export and saving the resulting calendar file to a logical location for safekeeping.
    3. Remove the following to the trash and restart your computer:
    Home > Library > Caches > com.apple.ical
    Home > Library > Calendars > Calendar Cache, Cache, Cache 1, 2, 3, etc. (Do not remove Sync Cache or Theme Cache if present)
    Home > Library > Preferences > com.apple.ical (There may be more than one of these. Remove them all.)
    ---NOTE: Removing these files may remove any shared (CalDAV) calendars you may have access to. You will have to re-add those calendars to iCal > Preferences > Accounts.
    3. Launch iCal and test.
    Hope that helps!

  • Get current event in iCal

    I'm trying to create a script that would run as a trigger to set my away message in Adium to currentEventName - eventLocation
    Theoretically, my code works, and it does... sometimes. I figure there is some bug in it I'm just missing. Any help would be appreciated. Note that this has to work for for repeated items. I have cut the date off at the minute since the date and time has to be exact - unless of course you know of a way to fix this. Thanks. Below is the code.
    set myEvent to "Unknown Event"
    --gets the current date minus the time
    set curDate to (weekday of (current date)) & ", " & month of (current date) & ¬
    " " & day of (current date) & ", " & year of (current date) as string
    set curTime to round ((time of (current date)) / 60) rounding down
    set curHour to round (curTime / 60) rounding down
    set curMin to curTime mod 60
    --fixes the 0 problem
    if curMin < 10 then
    set curMin to "0" & curMin as string
    end if
    if curHour > 12 then
    set today to curDate & " " & curHour - 12 & ":" & curMin & ":00 PM" as string
    else
    set today to curDate & " " & curHour & ":" & curMin & ":00 AM" as string
    end if
    --today should now be the correct time without the seconds
    set today to date today
    tell application "iCal"
    repeat with i from 1 to count of every calendar
    if myEvent is "Unknown Event" or myEvent is {} then
    set myEvent to (summary of every event of calendar i whose start date is today)
    set myPlace to (location of every event of calendar i whose start date is today)
    end if
    end repeat
    end tell
    if myEvent is {} then
    set myEvent to "Unknown Event"
    --display dialog "No event on " & today
    end if
    if myPlace is {} then set myPlace to "Unknown location"
    set myAway to myEvent & " - " & myPlace as string
    tell application "Adium"
    set my status type to away
    set my status message to myAway
    end tell
    PowerMac G5 DP 2.0Ghz   Mac OS X (10.4.6)   1.5GB RAM, 160GB SATA HD, 160GB ATA HD (enclosure)

    Apparently, it works even faster if executed from iCal (as opposed to running with the events tab closed).
    There were a couple of minor bug fixes, but I've tested it on a fake repeated event, and will see if it really works tomorrow.
    Known bugs:
    does not work for daily
    does not work for monthly (ie, things on the third sunday)
    For now though, this is fine as almost all my things are custom weekly events.
    Here's the code:
    --Get current time, current time without seconds, and day abbreviation
    set current_date to (current date)
    set today to current_date - (seconds of current_date)
    set now to (time of (current date)) - (seconds of (current date))
    log now
    log today
    set thisYear to year of (current date) as number
    set thisMonth to month of (current date) as number
    set thisDay to day of (current date) as number
    set thisDate to characters 1 thru 2 of (weekday of (current date) as string) as string
    log thisDate
    --Init vars
    set freq to ""
    set interval to ""
    set endDate to ""
    set myEvent to ""
    set myPlace to ""
    set setBool to false
    tell application "iCal"
    repeat with i from 1 to count of calendars
    if setBool is true then exit repeat
    repeat with j from 1 to count of events of calendar i
    set rec to recurrence of event j of calendar i as string
    set curDays to my getDays(rec, j, i)
    if thisDate is in curDays then --Check if the event ocurrs today
    set endDate to my getEnd(rec, j, i)
    --If the end date is equal or greater to the current date (minus seconds)
    if item 3 of endDate ≥ thisYear and (item 2 of endDate > thisMonth or (item 2 of endDate = thisMonth and item 1 of endDate ≥ thisDay)) then
    set eventStartTime to (start date of event j of calendar i)
    set eventStartTime to (time of eventStartTime) - (seconds of eventStartTime)
    if eventStartTime is now then
    set myEvent to summary of event j of calendar i
    set myPlace to location of event j of calendar i
    set setBool to true
    exit repeat
    end if
    end if
    end if
    end repeat
    end repeat
    end tell
    try
    if myEvent is "" then set myEvent to "Unknown Event"
    on error
    set myEvent to "Unknown Event"
    end try
    try
    if myPlace is "" then set myPlace to "Unknown Location"
    on error
    set myPlace to "Unknown Location"
    end try
    set myAway to myEvent & " - " & myPlace as string
    if myAway is "Unknown Event - Unknown Location" then set myAway to "Out. Call the cell."
    tell application "Adium"
    set my status type to away
    set my status message to myAway
    end tell
    --display dialog myAway
    (* Parse Recurrence *)
    on getFreq(str)
    try
    return word 3 of str
    on error
    return ""
    end try
    end getFreq
    --Not used right now, but I feel it should be...
    on getInterval(str)
    try
    return word 6 of str
    on error
    return ""
    end try
    end getInterval
    on getStartDay(eventNum, calNum)
    tell application "iCal"
    set startDay to items 1 thru 2 of (start date of event eventNum of calendar calNum as string) as string
    end tell
    return startDay
    end getStartDay
    on getEnd(str, eventNum, calNum)
    try
    set endDate to items 1 thru 8 of word 9 of str as string
    set endYear to items 1 thru 4 of endDate as string
    set endMonth to items 5 thru 6 of endDate as string
    set endDay to items 7 thru 8 of endDate as string
    set endYear to endYear as number
    set endMonth to endMonth as number
    set endDay to endDay as number
    log {endDay, endMonth, endYear}
    on error --It isn't a recurring event
    tell application "iCal"
    set endDate to end date of event eventNum of calendar calNum
    set endYear to year of endDate as number
    set endMonth to (month of endDate) as number
    set endDay to (day of endDate) as number
    log {endDay, endMonth, endYear}
    end tell
    end try
    return {endDay, endMonth, endYear}
    end getEnd
    on getDays(str, eventNum, calNum)
    set dayList to {"MO", "TU", "WE", "TH", "FR", "SA", "SU"}
    set recDays to {getStartDay(eventNum, calNum) of me}
    log recDays
    try
    repeat with i from 12 to length of str
    if word i of str is in dayList then
    set recDays to recDays & word i of str
    else
    exit repeat
    end if
    end repeat
    return recDays
    on error
    return recDays
    end try
    end getDays

  • How do I select current Event in Applescript?

    I'm trying to create an Applescript that will act on the actively selected Event in iCal. The equivalent functionality in Mail is accomplished by setting your variable to "selection".
    However, in iCal, selection is not a property, and I can't find anything similar. The only way appears to be to get all events in a calendar, then prompt to choose which one you want.
    Any help would be appreciated.
    MacBook Pro   Mac OS X (10.4.8)   iCal 2.0.4

    John, thanks for your answer. However, I was hoping for a programmatic way, just by having the Event selected, instead of having to type in begin and end dates each time I want to select an Event.
    Actually, I think I did figure out a way to do it last night, through a round-about way. I found someone else's script that copies the selected Event to the clipboard, then pulls out the first 2 lines of text, which are the Summary and Date. I then have my script repeat through all Events looking for the Event that has the same Summary. Once it finds it, I then have the reference to my selected Event.
    I patched it together with another script I found, so I can now manually change the Attendee status for Events, since iCal won't automatically process replies from MS Outlook users. If anyone's interested in my finished applescript, let me know, and I can post it here.

  • How do I get new events on my phone to sync with my desktop ical?

    How do I get new events on my phone to sync with my desktop ical?

    Hello juliebgerstel,
    I read your post, and it sounds as though you'd like to learn about calendar syncing. I have linked to an article that will instruct you on how to do that:
    iOS: How to transfer or sync content to your computer
    Thank you for contributing to Apple Support Communities.
    Cheers,
    BobbyD

  • System Events got an error: Can't get current configuration of service?

    I'm trying to connect/disconnect services through apple script, here is the error I'm getting for "Ethernet" "AirPort" (these services are configured in services tab)
    I am able to manualy On/Off these services without supplying admin password, therefore it might not be privilages issue.
    *Error message:*
    *System Events got an error: Can’t get current configuration of service id "099F7D16-4F3A-4D49-9111-A4DF0A645378" of network preferences.*
    Scipt used:
    tell application "System Events"
    tell network preferences
    tell current location
    get the name of every service
    set myService to service "AirPort"
    if exists myService then
    --get service properties of myService
    set isConnected to connected of current configuration of myService
    if isConnected then
    disconnect myService
    repeat while (get connected of current configuration of myService)
    delay 1
    end repeat
    end if
    connect myService
    end if
    end tell
    end tell
    end tell

    Hi Damian and welcome to Apple Discussions!
    One suggestion: try
    tell application "Finder" to open item 1 of docs
    (without 'using "Corel Painter 8"')
    As far as the Finder is concerned, "Corel Painter 8" is just a string of characters. And telling the Finder to open a file is just the same as double-clicking it: the Finder knows which app to use - as long as these are native Corel Painter 8 docs.
    Hope this helps,
    H

  • ICal has lost all events after upgrade to 10.8.3.

    iCal has lost all events and calendars except for birthdays after upgrade to 10.8.3. If I sync to my iPhone, will it wipe them from the phone, or will it get the events from the phone?
    I have Time Machine working, but am unsure how to restore calendars from it.
    PLEASE HELP.   

    Not sure why you think having to re-authorize would indicate an incompatibility or problem with their software unless you meant you have to keep re-authorizing the plugin?
    Some plugins need re-authorization when you change a certain file or files in your system.. or if the file structure itself changes.. or the drive is renamed for example.. It could simply be that IK used a different form of authorization routine to their other plugins or versions of their plugins, with Amplitude 2.... Nothing to do with an incompatibility...or problems.
    Anyhow I am happy you got the matter resolved and yes, random bursts of white noise is a classic sign of a plugin running in demo mode and needing authorization or re-authorisation as I suspected in your case.

  • Ical not showing new events and older events as well

    Hi There,
    Since (as I recall) last monday, iCal started to work strange. Or, better put in other way: stopped working.
    I have three calendars only (personal, work and "no category), all of them syncing with iCloud. There are two other local calendars too (in "my mac"), but I don't use them and they are unchecked.
    I only use my macbook white and an iphone 3GS, also syncing with iCloud.
    I don't subscribe any external calendar and don't accept any kind of invitation. It is a basic-simple use: I set my appointments (throw the whole year) and want to see / edit them on iphone.
    Finally, I use reminders (on iphone) a lot and share the "personal" calendar with my with (she uses iCloud on her iphone and ipad).
    The problems are basic two (as I could indentify so far):
    1) I can't set new appointments on iCal. Or better: I may set, but cannot see it. For instance, when a double click the Feb 24th to set a appointment, nothing happens, but a "New event" apperars on iCloud, right way. Looks like that iCal is setting the event up, but it just does not show it. Lately, I've discovered that when I go to the week view in iCal, it shows the event, but it just don't appear on month or year views;
    2) There are a bunch of events that appear correctly on iCloud (and iphone) but just don't show up in my iCal.
    I've been trying to find a solution, already followed a couple of step-by-step possible solution (deleted local calendars, took off iClound accoun from iCal, deleted all files on specific folders in my library), but anything work out. It just don't work anymore.
    Scary...
    I have just quit iCal and started using iCloud as my main input way for may events.... Wonder if anyone else is facing something like this and if is there any sollution out there.
    Thanks a lot in advance and sorry for my bad English.

    i have a similar problem. i can't add any new events to my ical. i can do it on ical on icloud but not on the ical on my itouch. i can't edit them either. it tells me the event can not be saved because a calendar has not been chosen. it was working just fine yesterday and now it won't work.
    i'm new to this on line community stuff. i posted my questions but i don't know how i'm supposed to see any answers. i guess it doesn't matter that i even ask you this or reply to you because i don't plan to be able to see any comments to this. oh well. computer stuff is just crap  sometimes. i guess we have to learn to deal with it.
    my paper calendar NEVER gave me any problems. i would just pull out my trusty pen and write down my appointment and wallah! it was done. it wouldn't get erased or deleted or stop working.

  • ICal is not showing event time in month view

    For some reason, the time of my events stopped showing in iCal.  I get the event, but the time doesn't show unless I click on the event.  The time does show in week view, but I prefer to use month view.  This has not been an issue in the past, so I don't know what happened or if I clicked on something accidentally.  I tried going to iCal preferences, but I don't see anything that allows me to select "show time in month view" which has been suggested by other usI'm using OS X Yosemite.  Thanks.

    It appears that it is dependent on the size of the calendar window. If it is too squished to display, it won't.

  • ICal's month view events are spilling out and overlapping making unreadable

    iCal's month view events are spilling out of their day boxes and overlapping the events below them making it impossible to look at the month view and discern one's schedule.
    What's really odd is it only seems really a problem with the current month. January 2009.
    What can I do to remedy this situation?

    Okay, I figured out a simple remedy that was probably always intended by Apple. I had been pasting long text paragraphs from emails into the 'Subject' Header. When I paste the long paragraph of information in the "NOTES" area at the bottom of the dialogue box and just put a brief subject line in the header area this fixes the problem.
    This might seem like common sense, but Palm Desktop did not require this. I figured this out by trying Entourage. Entourage synching with the iPhone however works through iCal and deleted all my color coded Calendars that I had not backed up. In Palm Desktop I had 15 categories each with a color code.
    Now, when I put an address into the "Location" window why can't I tap that on the iPhone Calendar and have the GPS/Googlemap display this location on a map?

  • How do i get my events to change colors when i add new ones in my calendar

    How do I get my events to change colors when I add a new event in my calendar?

    When you add an event and you see the heading "Calendar", do you see a name to the right of it such as "Work"?  If you tap on the heading "Calendar" does it show you a list of calendars?
    I'm basing this on my experience using iCal on a Mac to sync with my iPad.  I created a number of calendars on the Mac and assigned them different colors.  Those appear on my iPad.  I don't know how to create additional calendars on the iPad alone - I must create them in iCal or MobileMe then they show up on the iPad.  Are you using a Mac or MobileMe?

  • How can I get the events from a java program?

    I want to make a monitor to watch a java program.How can I get the events from the GUI of this program some as mouse cliking, keyinput. So I can watch these in my monitor.
    Thanks

    Hi,
    To put a monitor to the events occuring in the GHUI u need to register required components with the appropriate EventListeners.
    Liek if u want to get notified when a mouse is clicked, then u need to add The MouseListener to the component which u want to be monitored.
    Say
    myFrame which is the JFrame object which shuld be monitored for the events.
    Then in ur program u have to add following code
    myFrame.addMouseListener( someObectReference );
    Here the someObjectReference should be an instance to a concrete class ..i.e. U write a class like the following
    public class MyMouseListener implements MouseListener {
    // override the followig methods
    public void mouseClicked(MouseEvent me){ sop("MOUSE CLICKED ON THE FRAME");}
    public void mousePressed(MouseEvent me){}
    public void mouseReleased(MouseEvent me){}
    If u dont want to use another class for listening to the events. Then u can make teh current class monitor the events. To do so ur class should implement the appropriate listener and should override the required methods.
    and u should say myFrame.addMouseListenet( this );
    thats it

  • How to get current URL from Internet Explorer ?

    Hi,
    I have design an add-on for IE and I'm
    trying to get URL from IE which is currently opened that is which is currently user sees. Is there any way to get it? I want to store that address in label and use it for something useful. Is it possible with C# ?
    I have did the following code to get current URL but it showing last opened URL instead of current URL which is user see
    using SHDocVw;
           SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
                         string filename;
                         foreach (SHDocVw.InternetExplorer ie in shellWindows)
                             filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
                             if (filename.Equals("iexplore"))
                               label1.Text=ie.LocationURL;
                               label1.Text = ie.LocationName;
    and I have tried this one also 
    foreach (InternetExplorer ie innew ShellWindows())
       label1.Text = ie.LocationURL.ToString();
       label2.Text = ie.LocationName.ToString();
    Please give me any suggestion or code to solve this problem.
    Thanks.
    Priyanka

    You already got addon running in the active ie instance. You just need to catch the WindowStateChanged event in every instance so you can write down the last event with OLECMDIDF_WINDOWSTATE_USERVISIBLE somewhere. When you need the active IE instance, just
    pull from your save.
    Note an IE tab may crash and take your addon with it. It is better to start a broker process to store your global data.
    Visual C++ MVP

  • Getting key events without a jcomponent...

    Is it possible to get key events without adding a keylistener to a jpanel? I want a class of mine to manage input of it's own, but it has no reference to a jpanel. They don't necessarily have to be KeyEvents, but just some way to detect if a key has been pressed (like the arrow keys). How can I do this? Thanks.

    Lots of components can listen for key events.
    What does your class subclass?It doesn't subclass anything. I am creating a custom menu system for my game using images I have made for the tileset. I would like it to handle some keyboard events of its own. (Like if the down arrow is pressed, it will move the focus down to the next component on its own). Right now I am currently passing the key events from my fullscreen jpanel to the menu class and it is handling them that way. Thanks.

  • To get current data block name

    Hi;
    I have 2 data blocks on my form and I want to get current data block name on my form. How can I do this???
    Thank you

    Like Rosario said, use the :SYSTEM.CURSOR_BLOCK.
    you can also use :SYSTEM.TRIGGER_BLOCK in triggers to find which block was responsible of the firing event of a trigger.
    Do not use :SYSTEM.CURRENT_% variables in Forms 9i and above, those are only there for compatibility reasons.
    You can also check the online help for more details on :SYSTEM.% system variables.
    Tony

Maybe you are looking for

  • ISE 1.2 and load balancing...

    I'm looking into configuring load balancing behind F5's. I know this can be done and have read the documentation on what is required. I still have a couple of questions about it: 1. When you load balance the RADIUS traffic do you have to create separ

  • Ichat 4 video chat not working

    I am trying to use my ichat video function and it is not working. I use it at home with no problem but when i am at school it does not work. here is the error code Date/Time: 2008-09-08 14:05:27.796 -0700 OS Version: 10.5.4 (Build 9E17) Report Versio

  • Why can't I get wide screen when burning a dvd?

    My sequence is all 1920x 1080 HD footage in mpeg2. My photos are all 1920 x1080 px. In encore if I want to burn a standard DVD it automatically goes to 720x480 if I choose " mpeg2dvd" format. Why isn't there a wide screen mpeg2 dvd format?

  • IMac shown as UNKNOWN under "Attached Devices" on Netgear Router

    I have a small home network comprising my iMac G5 (10.4.7), and two XP laptops. One of the laptops is connected to a Netgear DG834PN Wireless Router via Ethernet Cable, and the other laptop and my iMac gets connection via wireless. Yesterday I sudden

  • How do i get an itunes instillation package?

    im trying to update my itunes and i get an error message saying that its on a network resource that is unavailable. it also says i need to find where the itunes instilation package is located to run the update. i have no idea where to look and quite