库“globalmousekeyhook”中的键盘事件问题

问题描述

在使用库“globalmousekeyhook”时,出现了两个问题:

问题 1:从单独的类调用时全局事件不起作用

- 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.

问题 2:应用事件运行异常

分别以两种形式编写了用于更改背景的代码

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

启动表单(Form1.Hide(); Form2.Show();)后,当您激活组合键(Ctrl + S)时 - 两种表单的颜色都发生了变化(只需要在活动表单中更改颜色).

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)