说说研究这个的起因: 妹子这几天心情不好,频发状态,为了随时了解她的动态,觉得写个接口时刻关注她是否发送新状态。mac下的通知中心是最好的消息提醒了,比ubuntu下的好多了,非常容易看到而且不烦人,所以想看看能不能调这个通知中心的接口。 系统编程肯定是可以了,但是我想用python写脚本,于是google一下,没有。改成英文找到了。。 几个关键的知识点: osascript https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/osascript.1.html https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptX/AppleScriptX.html#//apple_ref/doc/uid/10000156-BCICHGIE 这应该是osx的系统级脚本语言,类似之前windows的vbscript吧。最早就用VBscript就能写界面程序,只要一个vbs脚本,学那个的时候才刚研究编程。 无需写个脚本,osascript有个-e参数,后面可以跟一个多行的脚本语句。就这个了。 想弹出一个提示,只要终端执行:osascript -e 'display notification "Content ! !" with title "Title"' subtitle display notification "message" with title "title" subtitle "subtitle" sound声音 display notification "message" sound name "Sound Name"声音文件都在 ~/Library/Sounds /System/Library/Sounds ok,直接python调一下语句就行了。后边两个是看stackoverflow上总结的,只管记录一下,以后说不定用到,应该问的也能查到。 通知中心的偏好设置里边,appscript编辑器必须在-在通知中心里边,这样才会有提示。 https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW224

上一篇:
下一篇:

相关文章:

Categories: 博客记录

0 Responses so far.

Leave a Reply