02 appleScript基础知识
1 什么是AppleScript
?
AppleScript
是一种用于mac OS
的自动化操作语言。
2 常用示例
2.1 获取当前激活的应用名
tell application "System Events"
set frontmostProcess to first process where it is frontmost
set appName to name of frontmostProcess
end tell
display dialog (appName)
2.2 指定应用执行javascript
tell application "Google Chrome"
execute front window's active tab javascript "document.querySelector('video').paused ?document.querySelector('video').play() : document.querySelector('video').pause()"
end tell
2.3 激活应用
tell application "Google Chrome" to active
2.4 退出应用
tell application "Activity Monitor"
quit
end tell
//:xxx todo 省略10万字,后面再说