gmamaladze / globalmousekeyhook

This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
MIT License
1.05k stars 257 forks source link

Sequence with "Control, Control" not working #110

Open LukasFiniarel opened 5 years ago

LukasFiniarel commented 5 years ago

I want to open a WPF Window if a user presses the (left) Control button two times. This is my Code:

var openWindow = Sequence.FromString("Control, Control");
Action actionOpenWindow = () => { new MyWindow().Show(); };
assignment = new Dictionary<Sequence, Action>{{openWindow, actionOpenWindow}};

IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
m_GlobalHook.OnSequence(assignment);

The Application starts correctly but the sequenze doesn't trigger my action. If I change the sequenze to "A,B", it runs perfectly.

toelli commented 4 years ago

Any updates on this? I have the similar issue when trying to trigger combination or sequence ending with Shift. Example: Combination.FromString("Shift+W") works but Combination.FromString("W+Shift") does not.

toelli commented 4 years ago

113 sequence-control-control-fix

I think I found the issue and this fix has solved both your problem & mine according to my testing.

ghost commented 4 years ago

113 sequence-control-control-fix

I think I found the issue and this fix has solved both your problem & mine according to my testing.

It doesn't work. Pressing any key after control fire action. Also, It doesn't work for Alt key. For example "ALt, Alt";

chrkon commented 3 years ago

Hi @toelli, hi @kokabi1365, I have added the e.KeyCode.Normalize() fix (#113) and the following lines to the ConsoleHook Example.

  var map = new Dictionary<Sequence, Action>
            {
                {Sequence.FromString("Control+Z,B"), () => Console.WriteLine("CTRL-Z followed by 'B'")},
                {Sequence.FromString("Control+Z,Z"), () => Console.WriteLine("CTRL-Z followed by 'Z'")},
                {Sequence.FromString("Control,Control"), () => Console.WriteLine("CTRL followed by CTRL")},
                {Sequence.FromString("Shift,W"), () => Console.WriteLine("Shift followed by 'W'")},
                {Sequence.FromString("W,Shift"), () => Console.WriteLine("'W' followed by Shift")},
                {Sequence.FromString("Alt,Alt"), () => Console.WriteLine("Alt followed by Alt")},
                {Sequence.FromString("Escape,Escape,Escape"), quit}
            };

So I was able to test some sequences:

Any comments?

ghost commented 3 years ago

"Control, Control" doesn't work yet.