简体   繁体   English

在活动日通过终端启动Mac应用程序

[英]Launch Mac Application on Event day by Terminal

i have an task to create event on particular day and time i have to open any sample application automatically so far i done created an event on date and time but i dono how to add script to launch application 我有任务要在特定的日期和时间创建事件,到目前为止,我必须自动打开任何示例应用程序,我已经在日期和时间创建了事件,但是我不知道如何添加脚本来启动应用程序

here my sample code: 这是我的示例代码:

osascript -e 'tell application "iCal" to make new event at end of calendar 1 with properties {start date:date "12, 19, 2016 1:02:00 PM", summary:"Demo"}'

here is another code which i found to open any Application in single command : 这是另一个我发现可以用单个命令打开任何应用程序的代码:

open -a iTunes 

The above code which is tested on Terminal and Event is created on calendar 上面的经过终端和事件测试的代码是在日历上创建的

Now what i actually Need this is it possible to combine this two script in single command and Test it ?(ie on particular date i want to launch my App automatically) 现在我实际需要的是有可能在单个命令中结合这两个脚本并对其进行测试?(即在特定日期我想自动启动我的应用程序)

You basically need to create a "open file alarm" with the path to some Applescript that opens the application: 您基本上需要创建一个“打开文件警报”,并带有打开应用程序的某些Applescript的路径:

tell application "iCal"
   tell calendar "My Calendar"
      set theEvent to event 1
      set theDate to (current date) - 3 * days
      tell theEvent
         make new open file alarm at end with properties {trigger date:theDate, 
            filepath:theFile}
      end tell
   end tell
end tell

See example . 参见示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM