how to make a script "type in" the contents of the clipboard?

I need to RDC into a restricted-use system using Microsoft’s Remote Desktop Connection. On the Windows system, I am not allowed to copy (reasonable, to protect confidential data) nor to paste, which is not reasonable, as I often would have some piece code from elsewhere that I would love to have on the system.

However, I am obviously allowed to type. My questions is, what is the best practice for such a situation?

My guess: Could I have an AppleScript “typing” everything on the clipboard after using a keyboard shortcut? I know about the keystroke action of the System Events app, but I am not sure how to make it type the contents of my cliboard, nor how to activate it with a keyboard shortcut. I hope it would work even as RDC is active and the cursor is somewhere on the remote desktop…

Thanks!

Model: MacBook Pro (13"), early 2011
AppleScript: 2.4.1
Browser: Safari 535.14
Operating System: Mac OS X (10.7)

You are definitely doing a workaround here, since RDC does not support Applescript except in a limited way when driving it via the GUI. I was hoping CoRD had some limited support, but no go there.

So your suggestion seems about the best you can do. Among other things, you’ll need to be sure the correct RDC window is active before “typing”. And that also assumes the correct app is active in the Windows session.

You can then get the contents of the clipboard with something like:

(the clipboard as text)

If you add your applescript to your scripts folder (/Library/Scripts or ~/Library/Scripts) you can then use the Keyboard Shortcuts tab of the Keyboard CP inSystem Preferences to then map the menu item in the Scripts menu to a keystroke.

That probably doesn’t answer all your questions, but at least gives you a start.

Simon.