How to use Applescript to print out a certain calendar at 7am every morning?

Hey guys,
I am trying to use AppleScript to print out one of my calendars each day at 7am every morning.
I have come up with this so far:
tell application "Calendar"
       view calendar "My Appointments" at (my (current date))
       switch view to day view
       activate
                    tell application "System Events"
                 keystroke "p" using command down
                 delay 1 -- (seconds)
                 tell process "Calendar"
                                                  tell window "Print"
                                                                 if value of checkbox "Calendar Keys" is not 0 then
                                  click checkbox "Calendar Keys"
                           end if
                                                  end tell
                                   end tell
                    end tell
end tell
The problem with this is that it will print out whatever calendars are currently viewable. I can't figure out how to tell it to deselect other calendars and just select the one I want. I also want to tell it to print this out at 7am every morning.
Any help would be very appreciated!

If you wanted to do the printout over multiple days, you would be best to loop through each day's events in the way the current script does, but to put a new loop around it that gets each new day's data:
--opens a temporary file
set fileRef to open for access ((path to desktop) as string) & "meetings.txt" with write permission
--effectively empties the file
set eof fileRef to 0
tell application "Calendar"
          set dayCount to 9 --this will be the number of days to look forward (not including today)
          repeat with currentDay from 0 to dayCount
                    set startList to {}
  --get's today's date
  --set startRange to ((current date) + 12 * days) -- I used this for testing, to point to a day that had many appointments.  I've left it so you can use it, too.
                    set startRange to ((current date) + (currentDay * days))
  --set the start of the range to previous midnight
                    set hours of startRange to 0
                    set minutes of startRange to 0
                    set seconds of startRange to 0
  --set end of the range to next midnight
                    set endRange to (startRange + 1 * days)
  --get today's events
                    set todaysEvents to get (events of calendar "My Appointments" whose (start date is greater than startRange) and (end date is less than endRange))
  --make a new list with start time of the event for sort purposes
                    repeat with theEvent in todaysEvents
                              set end of startList to {startdate:start date of theEvent, eventID:theEvent}
                    end repeat
  --sort using a bubble sort (suitable for short lists)
                    repeat with i from 1 to (count of startList) - 1
                              repeat with j from i + 1 to count of startList
                                        if startdate of item j of startList < startdate of item i of startList then
                                                  set temp to item i of startList
                                                  set item i of startList to item j of startList
                                                  set item j of startList to temp
                                        end if
                              end repeat
                    end repeat
  --empty the original list
                    set todaysEvents to {}
  --repopulate the list in correct chronological order
                    repeat with theEvent in startList
                              set end of todaysEvents to eventID of theEvent
                    end repeat
  --write today's date to the file
  write (date string of startRange & return & return) to fileRef
  --if there are no events, write this to the file as well
                    if length of todaysEvents is 0 then
                              write "No events" & return & return to fileRef
                    else
  --process each event into format: hh:mm-hh:mm/new line/event summary
                              repeat with theEvent in todaysEvents
                                        set startdate to start date of theEvent
                                        set enddate to end date of theEvent
                                        set startHours to hours of startdate as string
                                        if length of startHours is 1 then set startHours to "0" & startHours
                                        set startMins to minutes of startdate as string
                                        if length of startMins is 1 then set startMins to "0" & startMins
                                        set starttime to startHours & ":" & startMins
                                        set endHours to hours of enddate as string
                                        if length of endHours is 1 then set endHours to "0" & endHours
                                        set endMins to minutes of enddate as string
                                        if length of endMins is 1 then set endMins to "0" & endMins
                                        set endTime to endHours & ":" & endMins
  --write the event to the file
                                        set theSummary to (starttime & "-" & endTime & return & summary of theEvent & return & return) as string
  write theSummary to fileRef
                              end repeat
                    end if
  write return to fileRef
          end repeat
end tell
--close the file
close access fileRef
--print the file
set theFile to (((path to desktop) as text) & "meetings.txt") as alias
tell application "TextEdit"
          print theFile without print dialog
end tell

Similar Messages

  • How to make it repleatedly printed out by using timer??

    Dear Friends:
    I have following code to run, When I press R to repeat println, only 1 line print out,
    But I hope to make it continueously print out.
    How to make it repleatedly printed out until I press CTRL + C key ??
    Thyanks
    import java.util.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    public class CertainAndRepeatTime{
      public static void main(String[] args) throws IOException{
        int delay = 1;
        Timer timer = new Timer();
        ActionListener actionListener = new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              System.out.println("Hello World Timer");
        System.out.println("What do you want (Certain time or Repeat time)?");
        System.out.print("Please enter \'C\' or \'R\' for that: ");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String ans = in.readLine();
        System.out.print("Please enter  ans=" + ans  + " IsTrue=  " + (ans.equals("R") || ans.equals("r")) +"\n");
        if (ans.equals("C") || ans.equals("c")){
          //System.out.println("This line is printed only once start...");
          timer.schedule(new TimerTask(){
            public void run(){
              System.out.println("This line is printed only once.");
          },delay,1);
        else if(ans.equals("r") || ans.equals("R")){
          timer.schedule(new TimerTask(){
            public void run(){
              System.out.println("This line is printed repeatedly.");
          },delay, 1000);
        else{
          System.out.println("Invalid Entry.");
          System.exit(0);
        System.exit(0);
    }

    The Timer is working fine, but because it runs in another Thread, your program is ending before the Timer can repeat.
    The simplest way to make your program wait until it is force-quitted as you describe would be to make an infinite loop (although this isn't very good practice), like this:
        else if(ans.equals("r") || ans.equals("R")){
          timer.schedule(new TimerTask(){
            public void run(){
              System.out.println("This line is printed repeatedly.");
          },delay, 1000);
        while(true){} //This will make your main thread hang.
        }A better way, though, would be to listen again with your System.in reader until they enter a letter that means quit.

  • How to use AppleScript to set "character fill color" in Pages 5.2?

    For Pages 5.2 on OSX 10.9.3, what is the correct applescript for changing the "character fill" of text in pages. 
    If you highlight text, you do this via your mouse in the inspector by clicking "style," "advanced option (the gear wheel to the right of bold, italics, and underline), "character fill color (clicking on the multi-color circle, not the dropdown menu), and then choosing a color that comes up in the "colors" dialogue box.
    I've looked all over and cannot find how to use applescript to set the character fill color in pages. 
    In some examples (not directly related) I see "character fill" used. 
    In others, I see "colorfill." 
    Basically, I want to use applescript, embedded in a keyboard maestro macro, to change the background color of the text (not the text color itself) to particular colors. 
    Given the changes and updates to Pages this year, and to applescript, what's the easy way to do this?
    Thanks!
    Chuck

    Pages v5.2 still does not include selection-object, or character background color entries in its AppleScript dictionary, as does Pages ’09. Indirectly, using System Events, you can get the text selection in Pages v5.2, but then you can do nothing to change the selection. No assurances as to if or when Apple will mature the AppleScript dictionary support for Pages v5 series.

  • How to use NODIM func with out it's values being rounded

    I created a new calculated key figure in Query Designer 3.x, and used the function NODIM() - Value with out dimensions. When I use this function, the values are rounding off to the nearest value.
    For example, I have a value 0.000075 US$, when I use NODIM function the value is displayed as 0.000080. Value is getting rounded to nearest value.
    I tried using absolute value it did not work.
    Can any one tell me how to use NODIM function with out it's value being rounded to nearest value.
    Thanks,

    Hi,
    According to your description, you might want that "Notice" field has a default value when form is created and users can be able to change the value of that
    field.
    As a workaround, you can add an action rule in “Name” field via InfoPath to fill the default value in “Notice” field only when “Name” field is not blank and “Notice”
    field is blank.
    Settings of the rule are as below, you can modify it based on your need:
    Here is a link about how to add an action rule in InfoPath form, you can use it as a reference:
    https://support.office.microsoft.com/en-us/article/Add-rules-for-performing-other-actions-5322d726-b787-4e5f-8d37-ba6db68b451d?CorrelationId=8a64c12f-aa60-4d90-b1f9-a44fcc4e74b5&ui=en-US&rs=en-US&ad=US
    Best regards
    Patrick Liang
    TechNet Community Support

  • How can we force everything printed out of Oracle to print greyscale

    How can we force everything printed out of Oracle to print greyscale and not color?
    I looked in CUPS and there is no way to distinguish what color scale to output, it has to come from the source (Oracle) with that parameter.
    I have confirmed that printers are already set to force to greyscale, but this is overridden by the date coming from CUPS rather than a Windows machine. Please investigate options to force all print jobs from Oracle, whether as outputs from concurrent programs or the ctrl-p print window contents function, to greyscale.
    EBS release 11.5.10.2
    Thanks in advance.

    It's actually setup at the printer level.
    Check the printer color mode setup by accessing the printer web interface at http://<printer name found in Oracle>.
    Thanks,
    PS.

  • How can I get a print out of a conversation that was done through text on 08/23/2014?

    how can I get a print out of a conversation that was done through text on 08/23/2014?

    On what kind of phone model? Some phones depending on the OS have SMS Backup applications available.
    You need a court order to get transcripts for the last 6 days or so of text messages directly from Verizon Wireless.

  • HT4968 Can I print out my iCloud Calendar?

    I use my calendar for my whole family but only some of us have access to iCloud (younger members do not have smart phones). I would like to print out a weekly calendar for posting in a central location.
    When I simply use ctrl-P, I get a useless version without the full formatting to make it readable.
    How can I print out a copy that looks like what I see on my screen?

    If you are syncing the calendar with Outlook, print it from Outlook.  If not, try taking a screenshot and print the image.

  • How can i use query in Print out

    I am going to insert some Item's properties to print out of good issue, I dont know how can I use query in this tools?

    Hi,
    Please go through the following documentation on the service market place under the landing pages for
    cross topics:
    https://sapneth1.wdf.sap.corp/~form/sapnet?_FRAME=CONTAINER&_HIER_KEY=701100035871000437965&_OBJECT=011000358700003137952006E&_SCENARIO=01100035870000000183&
    Regards,
    Abhinav Banerjee
    SAP Business One Forums Team.

  • Using Applescript to print calendars in MS Outlook

    I print my daily in portrait orientation, with the task list.  I like to print my weekly calendar in landscape orientation, without the task list.
    I'm new to Applescript and have been poking around in the Outlook library but can't find anything there that indicates how to even just print Calendars using Applescript.
    Is there a way to change the page setup to landscape orientation, then print the weekly format (without tasks) and the reset the print orientation to portrait?
    Thanks in advance-
    Tom
    Mac OS 10.6.8

    You mention using AS to set the preset. Do you know how to do that?
    I'm trying to find out how to use a print preset in Applescript on 10.6.7. The only things I've found on the internet suggest running a terminal command that changes the preset, but they are talking about 10.4 and it doesn't work in 10.6. I can't find the answer to this anywhere. It seems like it should be rather simple.

  • How to use AVDocPrintPagesWithParams for printing without any prompt dialog or alert message ?

    Hi Friends,
    I have a problem to print the pages of a pdf, but with out any dialog box prompt. So I choosed the api AVDocPrintPagesWithParams(avDoc, avDocPrintParam);
    But I don't know how to set parameter for 2nd parameter of the funtion. My requirement is I want to print pdf's using default printer of the system i.e. Print As PDF using Abode PDF print.
    Page Dimension should be same as previous, with postscript value 3 (best print).
    I have used AVDocPrintPages (AVDoc doc, ASInt32 firstPage,ASInt32 lastPage, ASInt32 psLevel, ASBool binaryOK,ASBool shrinkToFit); But it gives an error message for some pdf's that PDF may not printed correctly because font information couldn't be found.
    So can anyone let me know please how to set the parameter of AVDocPrintParam, so that I can use AVDocPrintPagesWithParams and do the same job.
    Thanks and Regards,
    Saffiuddin Sheikh.

    Dear lrosenth,
    I am into an operation where I have check whether each objects falls inside my rectangular region or not. For this I am taking help of BBox and matrix information. The problem is that when I find PDF's those have form or container objects, their matrix and BBox is depenedent on matirx of the form or container containing them.
    In most cases by adding(concetinating ) the matrix value of form and the element gives the correct matrix, BBox value, but some cases I am yet to understand the behaviours. So to avoid these form and container for our immidiate project delivery, we are using this option to print the pdf and then process for checking the position of elements.
    My original requirement is :
    How to know objects position inside a form or container ?  
    This is just an alternative time being way to achieve the task. But if you have any idea of how to detect postion of objects inside form/container then please let me know. 

  • Don't know how to use the air print with my ipads.

    i just bought an mg3222 printer and i don't know how to figure out how to use air print with my ipad and ipad minis. Can anybody help??? Thanks

    Hello.
    In order to use the printer with your iOS devices, please make sure that the units are all connected to the same WI-Fi router.  Once this has been done you should be able to print.
    The initial Wi-Fi setup of the MG3222 would have to be done from a compatible Windows or Mac OSX computer.
    If additional assistance is needed, feel free to call us at 1-800-OKCANON.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • How to use i cloude with out wifi

    How to use icloude with out wifi. I never backed my contacts up in iclode, and now my wifi does not work.

    icloud is on the internet to be able to use it one have to have an Internet connection over wifi or over 3g

  • Flex 3  :How to use trace for printing data in console

    Hi ,
    I heard that we can use trace to print data on to Flex Builder 3 console . But when i tries it was of no luck .
    The below is a simple program , in which i was out of luck .
    public function callMe():void
                trace("AAA");
    <mx:Button id="Register" name="Register" label="Register" height="23" click="callMe()"/>
    Here in the above porogram , after clicking the Button , i cant see 'AAA 'related  inside my Flex Builder .
    Any help ??
    Thank you .

    Hi Kiran
                Make a break point at trace line and debug the application  There u can find the message u typed in console..  trace works only under debugging mode... not in development mode ..
               Have a nice day
    Thanks
    Ram

  • Can I use eprint to print out document as duplex?

    I was able to print out using eprint service. But it only print one side per page. I am just wondering can I print out both page? Thanks.

    MTU,
    The ePrint Services are not designed to double side "duplex". 
    I hope this helps you.
    If I have SOLVED your issue, please feel free to provide KUDOS and make sure you mark this thread as SOLUTION PROVIDED!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • How to use javascript to print on the client side

    hi all,
    Now i'm facing a problem:
    I want to use javascript to print something(for example, a table) on the client side. So i must get a connection with the printer installed in the client computer.
    some says that getObject() function can do this,but i don't know how?
    Who please help me!

    window.print();

Maybe you are looking for

  • Cannot call ANY stored functions from my Java program

    My problem is that I cannot call ANY stored procedure from my Java program. Here is the code for one of my stored procedures which runs very well in PL/SQL: PL/SQL code: CREATE OR REPLACE PACKAGE types AS TYPE cursorType IS REF CURSOR; END; CREATE OR

  • Enter the document number error in BAPI_SALESORDER_CHANGE

    Hi, please help me on the below error: Call of BAPI_SALESORDER_CHANGE gives us an error V1 045 "Enter the document number". We are sure the call is proper (document number is send). The errors occurs in function module SD_SALES_DOCUMENT_READ in lines

  • Mail Message

    I want to recieve when the person I send an email, recieves the email and then I want to recieve an alert when the person reads the email. Is this possible in Mail?

  • Career advice : Oracle apps technical versus other roles

    I've 7 yrs exp & over 5 yrs in Oracle Apps(R12 & Fusion(4.5 yrs)) as applications developer. Even now, as TL/PM I don't see my role evolving as you are still expected to do hands on various technologies. How can I become fully functional (without hav

  • Lighting Effects Renders All Black

    I ran CleanMyMac 2 and it must have tossed out something -- because now Filter > Render > Lighting Effects = ALL BLACK. And the adjustment and hotspot circles no longer appear. See here: https://www.dropbox.com/s/mnld1efjfg8qlrc/Screen%20Shot%202014-