While it won't help with your actual request (to save a string to a remote keypress), I may be able to help. I have an HTPC that I RDP into frequently, and was frustrated that, after doing so, I'd have to put in the password again from my couch. So, I created a batch file on the desktop that runs this command:
C:\Windows\System32\tscon.exe 1 /dest:console
That will disconnect the RDP session without locking the computer. To disconnect, I just double click it.
*Note: I have found that sometimes, I have to put in 2 instead of 1 in that command. Haven't figured out why, exactly, but experience tells me it happens. If that happens for you as well, you can just put the command in the batch file twice, once with a 1 and once with a 2.