2016-12-24 81 views
0

我如何獲取有關一天活動的信息?從Calendar.app獲取活動的詳細信息

E.g.獲取今天發生的所有事件,他們的時間,被邀請者等。

最終目標是將此接口與手電筒實用程序進行接口,所以我將把python subprocess中的applescript查詢包裝起來,並使用該python中的結果程序。

+0

您是否嘗試過使用數據庫包含兩個表(一個是日期,一個是事件)? – Ronikos

+0

@Ronikos我如何從日曆中獲取事件? – theonlygusti

+0

我誤解了這個問題。你想使用蘋果腳本從Calendar.app獲取數據,然後將其傳遞給python? – Ronikos

回答

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 
+0

與myEvent進行交互的API是什麼?如果我從python腳本運行這個腳本,我怎麼能把每個'myEvent'的細節傳回python調用者? – theonlygusti

+0

我不是Python的專家,對不起。如果你用類似'return xxx'的方式結束你的Applescript,通常它會把xxx給回腳本的調用者;我在終端/ shell命令中使用了這個。它可能與Python相似? – pbell