我正在尝试制作一个简单的AppleScript,其中包含以下内容:
切换到Microsoft Word 类型* 按粘贴(命令v) 按返回
我想出了这个,但它不起作用......任何想法为什么?
tell application "System Events"
tell application process "Microsoft Word" to activate
keycode(42)
keycode(118)
keycode(3)
end tell
end tell
答案 0 :(得分:2)
您以错误的方式使用密钥代码并且您的tell块不正确请尝试此
tell application "Microsoft Word"
activate
tell application "System Events"
tell application process "Microsoft Word"
key code 42
key code 118
key code 3
end tell
end tell
end tell
答案 1 :(得分:2)
一般来说,如果您尽可能使用文本而非密钥代码,则代码更易于编写且更易读。
tell application "Microsoft Word"
activate
end tell
tell application "System Events"
tell application process "Microsoft Word"
keystroke "*"
keystroke "v" using command down
keystroke return
end tell
end tell