Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Trying to paste clipboard info into TextEdit

I am new to AppleScript, but from what I've been reading, this should a fairly simple task. I'm trying to do the following:

  • Create a new TextEdit document
  • Paste the contents fo the clipboard into the document

Current system configuration:

  • iMac with an Intel Core i5
  • OS X 10.8
  • "Enable access for assistive devices" in System Preferences is checked.


This is the code I am using:

tell application "TextEdit"


activate

tell application "System Events"

tell process "TextEdit" to keystroke "V" using {command down}

end tell


end tell


The code compiles without any issues. When I run the scrip in AppleScript Editor, it starts TextEdit and then I hear a beep. When I export the script as an application and run it, TextEdit starts, I do not hear a beep, but no text is pasted. I appears that the TextEdit program does not have the focus when the paste command attempts to run.

Any help would be greatly appreciated!

OS X Mountain Lion (10.8)

Posted on Oct 13, 2012 3:57 PM

Reply
Question marked as Best reply

Posted on Oct 13, 2012 4:08 PM

Here:


tell application "TextEdit"

set text of (make document) to the clipboard

end tell


(70705)

4 replies

Trying to paste clipboard info into TextEdit

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.