简体   繁体   中英

C# Keyboard Key detection precedence issue

I have an application which detects pressed keys on C# winform. The problem is on client side there are some other applications which also detects the pressed keys and suppresses them and because of that my App's form does not get the notification for the pressed key. I have used traditional form.KeyDown event to detect the key. How can I take higher precedence than the other application?

If you're worried about other apps basically stealing your keystroke then you need to look into Global Hooks which is almost definitely how they other apps are stealing yours. You can roll your own code or use a wrapper library that someone else already wrote.

You could be fighting a losing battle. Or at least an ever-escalating one. You've discovered that some other application is suppressing keystrokes. So you create a global hook so that you get the keystrokes first. But then that other application discovers that it's not first in line anymore, so it removes its own global hook and re-installs one in front of yours. You discover this and insert yourself in front of the list again. . .

It's a game of walls and ladders that nobody can win. So either deal with your application losing keystrokes or remove the offending application from the client machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM