Transferring text into a Remote Desltop (RDP) session

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roysubs
Posts: 425
Joined: 29 Sep 2018, 16:37

Transferring text into a Remote Desltop (RDP) session

Post by roysubs » 02 Dec 2022, 01:55

Looking for a bit of help in properly transferring / pasting data into locked-down RDP sessions, as those sessions sometimes have policies to prevent CTRL+V working. As we can pass keystrokes into the RDP frame then I can use AutoHotkey.

The below partially works, but I have some problems.

If I select many lines of text, sometimes it just stops after 50 or 60 characters. Maybe this has to do with keypresses being interpreted as key combinations inside the RDP session - this particularly occurs with " characters, so maybe it is following Dutch keyboard behaviour where pressing a " will wait for the next character to decide on what to output (for characters with accents etc)?

Is there some kind of way to do "really really raw!, or to disable any pre-processing / keyboard settings that might be interfering with the text transfer?

Code: Select all

^#!v::   ; Paste clipboard raw (also inside nested RDP sessions, but only if that session is *not* fullscreen)
    Sleep, 100
    ClipWait 1   ; Don't know if this is good, better would be to check for TEXT in clipbord otherwise fail
    tempClipboard := Clipboard
    Sleep, 100
    SetKeyDelay, 100, 50   ; Slowing down here, as seems required when putting passwords into an RDP lock screen
    SendRaw, %tempClipboard%
    SetKeyDelay, 10, -1	; Restore default delay between keys
    Sleep, 100
    Send, {Enter}
return

Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Transferring text into a Remote Desltop (RDP) session

Post by Rohwedder » 02 Dec 2022, 02:23

Hallo,
only a try, not tested on Dutch keyboard:

Code: Select all

^#!v::   ; Paste clipboard raw (also inside nested RDP sessions, but only if that session is *not* fullscreen)
    ClipWait, 0
    IF ErrorLevel ; no Text
		Return
	tempClipboard = %Clipboard%
    Sleep, 100
	SetKeyDelay, 100, 50   ; Slowing down here, as seems required when putting passwords into an RDP lock screen
    Loop, Parse, tempClipboard
	{
		SendRaw,% A_LoopField
		SendInput, {vkFF} ;To break key combinations
	}
	SetKeyDelay, 10, -1	; Restore default delay between keys
	Sleep, 100
    Send, {Enter}
return

roysubs
Posts: 425
Joined: 29 Sep 2018, 16:37

Re: Transferring text into a Remote Desltop (RDP) session

Post by roysubs » 02 Dec 2022, 08:18

This is amazing, thanks so much, it works perfectly, every character is being generated in the RDP session that has pasting disabled.

However, it is rather slow, and doing about 1 line every 3-4 seconds, so for a 100 line file, that's about 5 minutes. Is there a way to speed up the time between keypresses do you think?

Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Transferring text into a Remote Desltop (RDP) session

Post by Rohwedder » 02 Dec 2022, 08:44

I would try to adjust the SetKeyDelay, 100, 50. And perhaps:

Code: Select all

Loop, Parse, tempClipboard
{
	SendRaw,% A_LoopField
	IF (A_LoopField = """")
		SendInput, {vkFF} ;To break key combinations
}

Post Reply

Return to “Ask for Help (v1)”