基本上,我的目标是能够在AppleScript中使用Python的开始和结束日期作为参数。。在
import commands
cmd = """osascript -e 'tell application "Calendar"
set all_calendars to title of every calendar
if "SimpleCal" is in all_calendars then
set primary_calendar to "SimpleCal"
else
create calendar with name "SimpleCal"
set primary_calendar to "SimpleCal"
end if
set start_date_mod to date %s
set end_date_mod to date "Wednesday, August 14, 2013 at 8:10:00 PM"
tell calendar primary_calendar
set new_event to make new event at end with properties {description:"Imported with App", summary:"event_type", location:"", start date: start_date_mod, end date:end_date_mod}
tell new_event
make new display alarm at end with properties {trigger interval:-5}
end tell
end tell
end tell
'""" % ("Wednesday, August 14, 2013 at 8:00:00 PM")
status = commands.getoutput(cmd)
print status
使用strftime将python日期转换为Applescript可以强制转换为日期对象的合适字符串:
然后,在AppleScript部分,只需添加日期:
^{pr2}$相关问题 更多 >
编程相关推荐