首页 > 解决方案 > 使用 applescript 创建带有弹出对话框的日历事件

问题描述

我需要一些帮助,因为我是新手,感谢任何输入。我正在尝试设置一个脚本来创建一个日历事件,询问我事件的日期、时间和持续时间,但我搞砸了一些事情,因为它不断给我错误,例如 Can't make "19.12.1820:06:17 " 转换为类型编号,我猜它们与格式或其他有关?

tell application "Calendar"
activate
tell calendar "Work"
    set theCurrentDate to short date string of (current date)
    set theCurrentTime to time string of (current date)
    --Get event Summary
    display dialog "Enter event name:" default answer "Appointment"
    set eventName to text returned of the result
    --Get date
    display dialog "Please enter a date for your event" default answer theCurrentDate
    set eventDate to text returned of the result
    --Get time
    display dialog "Please enter start time" default answer theCurrentTime
    set eventTime to text returned of the result
    set eventStart to eventDate & eventTime
    --Get duration 
    display dialog "Please enter duration in minutes" default answer "120"
    set eventDuration to text returned of the result
    set eventEnd to eventStart + (eventDuration * minutes)
    make new event at end with properties {summary:eventName, location:"url Intercall: xxx PIN: xxx", start date:eventStart, end date:eventEnd, url:"url"}
end tell
reload calendars
end tell

标签: calendarapplescript

解决方案


推荐阅读