要使AppleScript能够从日历中运行,您可以使用以下代码示例:
tell application "Calendar"
set theEvents to every event of calendar "My Calendar" -- 替换为您的日历名称
repeat with anEvent in theEvents
if start date of anEvent ≥ current date then
-- 在此处添加您想要执行的代码
display dialog "Run code for event: " & summary of anEvent -- 示例代码:显示对话框
end if
end repeat
end tell
上述代码将从指定的日历中获取所有事件,然后遍历每个事件。如果事件的开始日期大于或等于当前日期,则可以在if
语句块中添加您想要执行的代码。在上面的示例代码中,我们使用display dialog
来显示一个对话框,您可以根据需要将其替换为其他代码。
请注意,您需要将"My Calendar"
替换为您要运行脚本的日历的名称。