在Growl的帮助下 文件 关于AppleScript支持和一些讨论 巴特阿隆顿 和 艾略特B. 在里面 评论 关于这个问题,我想出了以下AppleScript。
我已将此脚本保存为应用程序代理,您可以将其添加到登录项目中 系统偏好设置→用户&组→登录项目 。
基本上,此应用程序通过检测是否正在访问与使用相机相关的唯一可执行文件来工作。每当访问可执行文件时,应用程序都会将其通知为Growl:
重要的是要知道此脚本监视对可执行文件的访问...
/System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources/VDC.plugin/Contents/MacOS/VDC
完整的脚本
-- check if growl is running in order to avoid the "Choose Application" dialog
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
-- store time of last iSight access
global lastopened
set lastopened to do shell script "ls -lu /System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources/VDC.plugin/Contents/MacOS/VDC | awk '{print $6,$7,$8}'"
-- make the application ready for use with growl
if isRunning then
tell application id "com.Growl.GrowlHelperApp"
-- make a list of all the notification types that this script will ever send
set the allNotificationsList to ¬
{"iSight access monitor"}
-- register the script with growl
register as application ¬
"iSight access monitor" all notifications allNotificationsList ¬
default notifications allNotificationsList ¬
icon of application "FaceTime"
-- send the first notification right after the application is started
notify with name ¬
"iSight access monitor" title ¬
"iSight access monitor" description ¬
"last iSight access:
" & lastopened application name "iSight access monitor"
end tell
end if
-- monitoring routine: checks every 10s if the VDC executable has been accessed
on idle
tell application id "com.Growl.GrowlHelperApp"
set newopen to do shell script "ls -lu /System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources/VDC.plugin/Contents/MacOS/VDC | awk '{print $6,$7,$8}'"
if (newopen is not equal to lastopened) then
notify with name ¬
"iSight access monitor" title ¬
"iSight access monitor" description ¬
"new iSight access:
" & newopen application name "iSight access monitor"
set lastopened to newopen
end if
end tell
return 10 -- interval in seconds
end idle
ls -lu /System/Library/Quicktime/QuickTimeUSBVDCDigitizer.component/Contents/MacOS/QuickTimeUSBVDCDigitizer | awk '{print $6,$7,$8}'
。编写一个脚本,将其与growlnotify相结合,并使其在后台运行。 TA-DAA!