How to monitor for keystrokes pressed when outside the App?

纵饮孤独 提交于 2020-01-01 17:48:45

问题


I need a way in C# to monitor system-wide keys such as Ctrl+A, so I can act upon that.

How could I get such an event, even when the keys were pressed with my App no longer in focus?


回答1:


You can use the RegisterHotKey function to react system-wide to hotkeys. However, I wouldn't advise you to use something like Ctrl + A which has a meaning in many applications.




回答2:


I don't think there's a managed way to do that. At an API level you can register system-wide hooks or global hotkeys.

Writing a keylogger? :-)



来源:https://stackoverflow.com/questions/985989/how-to-monitor-for-keystrokes-pressed-when-outside-the-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!