Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map virtual key before triggering keybd_event #151

Merged
merged 1 commit into from
Feb 4, 2016

Conversation

mgmartel
Copy link
Contributor

I'm using RobotJS to simulate keyboard input into an RDP session. However, because the Windows RDP client listens for scan codes instead of the key codes (for security reasons?), simulating key events with RobotJS doesn't work. See this thread on SO.

This PR adds the correct scancode using MapVirtualKey. With this change, RobotJS can send key events locally and through an RDP session. Tested on Windows Server 2012 and Windows 10.

Cheers,
Mike

@octalmage
Copy link
Owner

Thanks Mike! Does this cause any issues for regular Windows users?

@Deltatiger do you see anything wrong with using scan codes instead of key codes?

@mgmartel
Copy link
Contributor Author

mgmartel commented Jan 6, 2016

As far as I can tell, there are no issues for regular Windows users. The key code is also still being used, as well as the scan code - this PR only adds a value for the optional second parameter to keybd_event, instead of leaving it 0.

I haven't found any documentation or issues that would suggest that setting the scan code could cause issues. I have only tested on Win10 and Windows Server 2012 though (both locally & through RDP).

@Deltatiger
Copy link
Collaborator

@octalmage I am not familiar with this concept so I did some googling and think this is good. It doesn't look like it will be of any difference to the normal (non RDP) user. So we can go along with this.

@mgmartel Could you please check your editor to make sure that it does not mess with the whitespace. More lines are tagged with whitespace removal than normal code change.

Good thing is even if we shift to SendInput this feature can be supported without any big modification to the logic.

@Deltatiger
Copy link
Collaborator

@mgmartel It would be better if the function was moved to CamelCase. The function still follows Macro naming convention. Since this is a normal function now proper changes should be made I guess.

@mgmartel
Copy link
Contributor Author

@Deltatiger I updated the PR to not include the whitespace changes, and I made the function camelCase. It's been a while since I formatted any code in C, so let me know if you think anything else needs updating.

@octalmage
Copy link
Owner

@mgmartel awesome thanks! I'll test this and get it merged.

@octalmage octalmage merged commit 4941c1c into octalmage:master Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants