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