1, 打开程序后, 模拟手键盘的输入(模拟tab键, 模拟依次按键, 以及按住Command+V键)
tell application "Mail"
activate
set theMessage to make new outgoing message with properties {visible:true, subject:"mysubject"}
end tell
tell application "System Events"
tell process "Mail"
-- repeat until focused of UI element 1 of scroll area 4 of window 1
-- keystroke tab
-- end repeat
keystroke "yiono"
--keystroke "v" using command down
end tell
end tell
2, 模拟菜单打开操作, 打开photo Booth应用,然后执行一个拍照的操作
tell application "Photo Booth"
activate
end tell
tell application "System Events"
tell process "Photo Booth"
delay 3
tell application "Finder"
set visible of process "Photo Booth" to false
end tell
tell menu bar 1
tell menu bar item "File"
tell menu "File"
click menu item "Take Photo"
end tell
end tell
end tell
end tell
end tell
本文介绍使用 AppleScript 在 Mac 上模拟键盘输入及菜单点击等操作。包括在 Mail 应用中模拟创建新邮件并输入内容,以及在 PhotoBooth 中模拟拍照过程。
1918

被折叠的 条评论
为什么被折叠?



