Send/SendRaw issue

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JBensimon
Posts: 118
Joined: 19 Nov 2017, 11:19

Send/SendRaw issue

Post by JBensimon » 31 Mar 2023, 10:11

I use a hotkey to "paste" the current clipboard contents into the window with focus by sending keystrokes, very useful for app windows that don't support a normal paste function (such as certain remote session windows and consoles), which comes in handy to enter complex passwords, long URLs, etc. when pasting isn't an option. This works perfectly with most such app windows, except (so far) with the VMware Remote Console app which exhibits the following behavior during such a pseudo-paste operation: as soon as one of the sent characters would require the use of Shift to type it in the current keyboard layout, all subsequent characters are entered as if Shift is still being pressed, i.e. as if it were never released as further characters were being typed on the keyboard.

Here is a stripped down sample script with a hard-coded password string that illustrates the issue:

Code: Select all

; "Paste as keystrokes" test

^+q::
Tooltip, You have 5 seconds to`nfocus the target window!
Sleep, 5000
Tooltip
SetKeyDelay, 80
SendRaw, bb1&fA(VTo3#2(7R
Return
What winds up in the target window instead of the expected "bb1&fA(VTo3#2(7R" is "bb1&FA(VTO#@(&R", i.e. all the characters after the first "&" (which is a shifted character in the US keyboard layout) are the shifted version of the expected character in that layout. [A more readable example is that sending "abcd@abcd" would result in "abcd@ABCD" being entered into the target window.]

I have tried the different flavors of Send modes (though I do need SendRaw since the clipboard contents I normally paste are arbitrary and unknown) as well as different SetKeyDelay settings, all without success so far.

As a further test, if I replace the SendRaw line in the sample script with the following line that uses Send and explicitly releases Shift after consecutive shifted characters, the result is correct, but this is not an option as figuring out the modified string for arbitrary keyboard layouts and string contents would be a massive undertaking:

Code: Select all

Send, bb1&{Shift Up}fA(VT{Shift Up}o3{#}{Shift Up}2({Shift Up}7R
Any ideas to make SendRaw work reliably even with such pathological app windows? Am I missing some magic setting or option? [I realize most people aren't in a position to test potential solutions since the issue is limited so far to the VMware Remote Console app, but consider it a thought experiment and I'll test promising suggestions.]

Thanks.

JB

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Send/SendRaw issue

Post by swagfag » 31 Mar 2023, 11:23

use SendText

JBensimon
Posts: 118
Joined: 19 Nov 2017, 11:19

Re: Send/SendRaw issue

Post by JBensimon » 31 Mar 2023, 11:47

I'm pretty sure Send, {Text}... is one of the things I already tried (based on the documentation's "this improves reliability because the characters are much less dependent on correct modifier state") but, if memory serves, the result was a mess that looked nothing like what I was trying to send (I'm still specifically talking about the result with a VMware Remote Console window). I'll test again next chance I get. Thanks.

JB

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Send/SendRaw issue

Post by swagfag » 01 Apr 2023, 00:20

if u say sending Shift Up fixes it, then just send it after each char

Code: Select all

mySendForPasswords(keys) {
	for each, key in StrSplit(keys)
	{
		SendRaw % key
		Send {Shift Up}
	}
}

JBensimon
Posts: 118
Joined: 19 Nov 2017, 11:19

Re: Send/SendRaw issue

Post by JBensimon » 01 Apr 2023, 20:55

Great minds ... That's exactly what I wound up doing, except that I used the more traditional Loop, Parse, ... command (still on v1.1).

Thanks for the reply.

JB

Post Reply

Return to “Ask for Help (v1)”