从Calendar.app获取活动的详细信息

时间:2016-12-24 09:15:20

标签: python macos calendar applescript

如何获取有关日期的信息?事件

E.g。得到今天发生的所有事件,他们的时代,受邀者等等。

最终目标是将其与手电筒实用程序连接起来,因此我将在python subprocess中包装applescript查询并使用该python程序中的结果。

1 个答案:

答案 0 :(得分:1)

以下脚本从所选日期的开始时间为0:00:00到23:59:59的日期获取所有事件:

property my_calendar : "Calendar"

set my_date to (current date) -- or any other date you want

copy my_date to Start_Date
set time of Start_Date to 0
copy my_date to End_Date
set time of End_Date to 86399 -- 23:59:59 in seconds

tell application "Calendar"
tell calendar my_calendar
    -- read all events betwen start and end dates
    set my_List to (every event whose (start date is greater than or equal to Start_Date) and (start date is less than or equal to End_Date))

    repeat with myEvent in my_List -- loop through each event
        --do something
        log (start date of myEvent) as string
    end repeat
end tell --Calendar
end tell -- application