Discussion:
Problems with SendInput and Remote Desktop Client
(too old to reply)
jrb1400
2007-09-03 01:36:02 UTC
Permalink
Hi all,

I am using Windows XP Pro. I have no directly connected keyboard and mouse
on my computer, but I do have devices that provide keyboard input. I have
written software to take the keycodes from the keyboard device and call
SendInput() to enter the keycodes into the Windows OS. This program is
running as a service, so it should have system-level privileges.

This keyboard simulation program works except for when I try to use the
Remote Desktop Client. My SendInput calls have no effect in the Remote
Desktop Window. The keystrokes do not appear. I can start the On-screen
keyboard and use it. The on-screen keyboard apparently is able to send
simulated keycodes (as generated by clicking on the virtual keyboard) to
Remote Desktop.

Even after I log in with the on-screen keyboard, the keyboard simulation
program still does not work.

I figured it was a problem with the selected desktop, etc so I ran a piece
of code that enumerates the Window Stations, Desktops and Windows. I
expected to see an additional Winlogon desktop but did not. Even when the
logon screen for the Remote connection weas active, the Remote Desktop
appeared in the lists as just another window beneath Station: <WinSta0> /
Desktop: <Default>. There was only one Winlogon desktop whether or not the
Remote Desktop client was active.

I have also tried keyboard_event instead of SendInput().

Are there any ideas on this ? What is the On-screen keybard program doing
that I am missing ?


Thanks in advance for your help,
Jay
jrb1400
2007-09-03 12:28:26 UTC
Permalink
I found the solution in another discussion thread.

Terminal Services needs the wScan field in the keyboard input structure for
SendInput(). Set it to MapVirtualKey()

-- Some older documentation had indicated that this field was ignored or not
used.

Jay
unknown
2008-08-04 12:24:16 UTC
Permalink
Hi,
Saw you post.
I have code working along the lines that you mentioned.
When it sends to Notepad in a non-TS window (normal Windows session), it sends uppercase ok.
However when it sends to the TS Window, the characters are always sent as lowercase.
Do you have that problem ?

Thanks,
Rob Crombie
robhp AT iprimus DOT com DOT au
Sten Westerback (MVP SDK 2005-6 :)
2008-08-04 13:49:16 UTC
Permalink
Post by unknown
Hi,
Saw you post.
My post? ;)
Post by unknown
I have code working along the lines that you mentioned.
Which lines? ;)
Post by unknown
When it sends to Notepad in a non-TS window (normal Windows session), it
sends uppercase ok.
However when it sends to the TS Window, the characters are always sent as lowercase.
If you haven't told it to CapsLock or so i guess it will enter the character
codes in lower case.
Which API are you using? SendInput() ?
Post by unknown
Do you have that problem ?
No. ;) Nor can i see what it has with GDI to do.

- Sten
praiseyahushua
2013-02-27 09:58:22 UTC
Permalink
jrb1400 wrote on 09/02/2007 21:36 ET
Post by jrb1400
Hi all
I am using Windows XP Pro. I have no directly connected keyboard and mous
on my computer, but I do have devices that provide keyboard input. I hav
written software to take the keycodes from the keyboard device and cal
SendInput() to enter the keycodes into the Windows OS. This program i
running as a service, so it should have system-level privileges
This keyboard simulation program works except for when I try to use th
Remote Desktop Client. My SendInput calls have no effect in the Remot
Desktop Window. The keystrokes do not appear. I can start the On-scree
keyboard and use it. The on-screen keyboard apparently is able to sen
simulated keycodes (as generated by clicking on the virtual keyboard) t
Remote Desktop
Even after I log in with the on-screen keyboard, the keyboard simulatio
program still does not work
I figured it was a problem with the selected desktop, etc so I ran a piec
of code that enumerates the Window Stations, Desktops and Windows.
expected to see an additional Winlogon desktop but did not. Even when th
logon screen for the Remote connection weas active, the Remote Deskto
appeared in the lists as just another window beneath Station: <WinSta0
Desktop: <Default>. There was only one Winlogon desktop whether or no
th
Remote Desktop client was active
I have also tried keyboard_event instead of SendInput()
Are there any ideas on this ? What is the On-screen keybard program doin
that I am missing
Thanks in advance for your help
Ja
Hello

I'm trying to use the following code but it's not sending the input into th
remote desktop client. Can anyone please offer some suggestions

Thank you in advance


rdpClient.Focus()

INPUT Input = new INPUT()

Input.type = 1
Input.ki.wVk = 0x41; //ASCII for letter 'A
Input.ki.dwFlags = 0; //Key is presse
Input.ki.dwExtraInfo = IntPtr.Zero

Input.ki.wScan = MapVirtualKey()

IntPtr pInput
pInput = Marshal.AllocHGlobal(Marshal.SizeOf(Input))
Marshal.StructureToPtr(Input, pInput, false)
SendInput(1, pInput, Marshal.SizeOf(Input))

Input.ki.dwFlags = 2; //Key is released on the keyboar
Marshal.StructureToPtr(Input, pInput, false)
SendInput(1, pInput, Marshal.SizeOf(Input));

Loading...