I would like to be able to use AppleScript to paste the clipboard's text into the foreground application. Every solution I can find online uses
tell app "System Events" to keystroke "v" using command down. However, I am running this script with a keyboard shortcut, so I may already be holding down keys when this command fires, which makes the paste fail because more keys are pressed than just
v. I know that I can use
delay to give myself time to release the keys, but that feels like a hack (and ideally the paste would be instantaneous).
Is there a way to use AppleScript to paste without simulating the shortcut cmd-v? Thanks.
Edit: Also, if there is a way to use AppleScript to copy selected text without simulating cmd-c, that would be much appreciated as well.