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

Add support for key modifiers (e.g. Control + Shift + A) #8

Open
nomis51 opened this issue May 18, 2021 · 1 comment
Open

Add support for key modifiers (e.g. Control + Shift + A) #8

nomis51 opened this issue May 18, 2021 · 1 comment
Assignees

Comments

@nomis51
Copy link
Contributor

nomis51 commented May 18, 2021

I see in your Example folder here a method called CombineKeys that is not currently available.

Do you plan to add key modifiers to the keyboard methods already available, such as KeyPress :
KeyPress(Key.A, Key.Control)

That's a very usefull feature for any kind of projects that manipulate the keyboard "like a human". Those things are currently doable in AutoHotkey and in other .NET Windows-only libs, so I hope it gets implemented here aswell.

Workaround I have to do now is to Key down a modifier, such as Control, then Key press my target key, then Key up the modifier. That's fine, just not clean in my opinion.

var robot = new Robot();

robot.KeyDown(Key.Control);
robot.KeyDown(Key.Shift);
robot.KeyPress(Key.A);
robot.KeyUp(Key.Shift);
robot.KeyUp(Key.Control);

// instead of just overlaoding the method with
robot.KeyPress(Key.A, new []{ Key.Control, Key.Shift })
@lucassklp
Copy link
Owner

If you take a look on CombineKey, it does the same that you proposed here. In fact it is not working as expected because I need to manage the modifiers flag when I do a keydown / keyup.

I have not tested yet but the solution looks like this guy did in this fork:

neil-hyd@7f7d87c

I'll test and if works I'll make a MR

@lucassklp lucassklp self-assigned this Nov 8, 2021
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

No branches or pull requests

2 participants