Reputation: 237
I am working on an Applescript to paste what was last copied to any current field. It is to be used with VoiceOver and the key code way (only way I know how) does not work all of the time.
tell application "System Events" to key code 9 using command down
say "paste"
Upvotes: 13
Views: 21844
Reputation: 268
tell application "myApp" to activate
tell application "System Events" to tell application process "myApp"
click menu item "Paste" of menu "Edit" of menu bar item "Edit" of menu bar 1
end tell
Obviously, replace myApp
with the name of your app.
Paste
keystroke
).Upvotes: 1
Reputation: 31801
There is a direct way to access the clipboard via the the clipboard
keyword:
tell application "System Events" to keystroke (the clipboard as text)
Reference:
Upvotes: 6
Reputation: 3792
I use keystroke:
tell application "System Events" to keystroke "v" using command down
I'm not aware of an error you should get, so you'll have to share.
Upvotes: 25