AppleScript 笔记
2015-10-08 12:36
495 查看
1. 清空回收站
tell application "Finder"
empty the trash
end tell
2. "咚" 一声儿
been
3. 可以执行shell代码
例如: do shell script "ls"
4.定义变量
set n to "12" as number
set m to 12 as string
display dialog n
display dialog m
5.打开应用
tell application "System Events"
tell process "Firefox"
set frontmost to true
end tell
end tell
6.每隔0.1秒 按键Hi 当按下 com 键停止
use framework "Foundation"
tell application "System Events"
tell process "TextEdit"
set frontmost to true
end tell
repeat
keystroke "Hi"
delay 0.1
set flag to my BWAND((current application's NSEvent's modifierFlags()), (current application's NSCommandKeyMask)) > 0
if flag is true then exit repeat
end repeat
end tell
on BWAND(__int1, __int2)
set theResult to 0
repeat with bitOffset from 30 to 0 by -1
if __int1 div (2 ^ bitOffset) = 1 and __int2 div (2 ^ bitOffset) = 1 then
set theResult to theResult + 2 ^ bitOffset
end if
set __int1 to __int1 mod (2 ^ bitOffset)
set __int2 to __int2 mod (2 ^ bitOffset)
end repeat
return theResult as integer
end BWAND
tell application "Finder"
empty the trash
end tell
2. "咚" 一声儿
been
3. 可以执行shell代码
例如: do shell script "ls"
4.定义变量
set n to "12" as number
set m to 12 as string
display dialog n
display dialog m
5.打开应用
tell application "System Events"
tell process "Firefox"
set frontmost to true
end tell
end tell
6.每隔0.1秒 按键Hi 当按下 com 键停止
use framework "Foundation"
tell application "System Events"
tell process "TextEdit"
set frontmost to true
end tell
repeat
keystroke "Hi"
delay 0.1
set flag to my BWAND((current application's NSEvent's modifierFlags()), (current application's NSCommandKeyMask)) > 0
if flag is true then exit repeat
end repeat
end tell
on BWAND(__int1, __int2)
set theResult to 0
repeat with bitOffset from 30 to 0 by -1
if __int1 div (2 ^ bitOffset) = 1 and __int2 div (2 ^ bitOffset) = 1 then
set theResult to theResult + 2 ^ bitOffset
end if
set __int1 to __int1 mod (2 ^ bitOffset)
set __int2 to __int2 mod (2 ^ bitOffset)
end repeat
return theResult as integer
end BWAND
相关文章推荐
- JavaScript将取代AppleScript?
- Swift语言与Applescript的区别?AppleScript的发展状况?
- AppleScript_1
- AppleScript学习笔记(一)初识AppleScript
- AppleScript学习笔记(二)AppleScript的四种数据类型
- AppleScript学习笔记(三)捕捉错误
- AppleScript学习笔记(四)条件语句和循环语句
- AppleScript学习笔记(五)文件夹,文件和路径
- AppleScript学习笔记(六)处理程序Handler
- MAC使用imessage自动发消息
- Mac OS中的自动化任务-AppleScript
- Mac 自定义"终端"快捷键
- AppleScript发送邮件
- AppleScript语言介绍(译文)
- 我的新玩具-AppleScript(四)
- 我的新玩具-AppleScript(三)
- 我的新玩具-AppleScript(二)
- 我的新玩具-AppleScript(一)
- AppleScript入门
- mac os x 设置终端快捷键