如何解决库“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 举报,一经查实,本站将立刻删除。