I'm trying to make a simple applescript which doesn the following:
Switch to Microsoft Word type * press paste (command v) press return
I came up with this but it won't work... Any ideas why??
tell application "System Events"
tell application process "Microsoft Word" to activate
keycode(42)
keycode(118)
keycode(3)
end tell
end tell
your using key code in the wrong manner and your tell blocks are not correct try this
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
In general your code is easier to write and much more readable if you use text wherever possible rather than keycodes.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.