2
votes

I am trying to use keybd_event() to press certain keys through to a remote desktop application. For the simplest test I am simply opening notepad in the remote session, and have the call keybd_event() run on the local computer with the current user focus on notepad.

Unfortunately it does not appear to be sending any input through to remote desktop.

If I run the application on the local computer with a local instance of notepad in focus, it types exactly what I want to type no problem.

Does anyone have any ideas why this won't work? Obviously I can type manually into the remote desktop session.

Thanks

1
Right click and try running your program as administrator? I had a problem sending key events and mouse events to task manager and running as admin worked.Brandon
Thanks for the response Brandon, unfortunately we've tried that to no avail.Raiden616
Have you tried other remote desktop programs? (for example, TeamViewer) It is usual to have problems with standard RDP, but other programs often haven't such strange limitations.Ilya
Thanks @Ilya, unfortunately that's not possible as we are remoting into a supplied PaaS server. So in essence, we HAVE to use RDP...Raiden616
Hmm it's weird that it doesn't register the input.. I can't test it as I don't have another computer handy atm.. However, you could try using SetWindowsHookEx and remove the LLKHF_INJECTED flag: msdn.microsoft.com/en-us/library/windows/desktop/… Maybe then it would register as a hardware event and go through. Though, I'm not sure if that actually is the issue.Brandon

1 Answers

1
votes

Any Remote Desktop program is a gateway to connect a remote system, it is a mediator. Sending any keyboard message to this program via any method (like keybd_event, SendInput, PostMessage etc.) will be silently absorbed by the RDP program. It simply wont consume it, and wont pass it to the connected resource.

Most probably (which I am not sure of), the program might have documented APIs to send some messages to it, like close-session, open-session, or to send-message-to-connected session. Using given API (function, COM interfaces whatsoever), you may send some input to connected resource.