Problems with Keyboard Events in library “globalmousekeyhook”

205 Views Asked by At

When using library "globalmousekeyhook", two problems arose:

Problem #1: Global events do not work when called from a separate class

- If place the code to activate Global Events in a separate class (in a method) and then call it from the main form (FormName_Load) - then Global Events stops working (nothing happens).

- If use the code to activate Global Events in the main form (FormName_Load), without wrappers - everything works.

Problem #2: App Events working strangely

Having written the code for changing the background, separately, in both forms:

// Install listener App [Combinations]
Hook.AppEvents().OnCombination(new Dictionary<Combination, Action> {
    { Combination.FromString("Control + S"), () => { this.BackColor= Color.Black; }
}});

After startup forms (Form1.Hide(); Form2.Show();), when you activate the key combination (Ctrl + S) - the color changed in both forms (need the color to change only in the active form).

0

There are 0 best solutions below