I need to paste a string of text to whichever application is open, and I’d rather not clear the pasteboard, in case something important is there, and I’d rather not turn every single character into a keyboard event.
Is there another way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could try using accessibility: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Accessibility/cocoaAXIntro/cocoaAXintro.html
though it may be overkill.
Another option may be to copy the current contents of the pasteboard to a local variable, replace it with your own string, perform your paste, then restore the original value back to the pasteboard. Depends on what you’re trying to do.