capturing keydown events
-
I havent done any programming in a few months now, and as such i kinda forgot alot of this stuff... i used to know the anwser to this question *i wrote a program using it before* but alas, i forgot. Anyways what i need is to have my program running in the background without focus and beable to detect when i press a combo of buttons on my computer, and have it regain focus agian. Its simple i know, but i just pretty much forgot how to do alot of programming, anyways thanks for your help guys. Do i have to catch api calls, if so can you kindly provide any of them or ways of finding them, im looking now for them but i think there has to be a easyier way, a managed .Net way. anyways thanks for your time. The Code Project Is Your Friend...
-
I havent done any programming in a few months now, and as such i kinda forgot alot of this stuff... i used to know the anwser to this question *i wrote a program using it before* but alas, i forgot. Anyways what i need is to have my program running in the background without focus and beable to detect when i press a combo of buttons on my computer, and have it regain focus agian. Its simple i know, but i just pretty much forgot how to do alot of programming, anyways thanks for your help guys. Do i have to catch api calls, if so can you kindly provide any of them or ways of finding them, im looking now for them but i think there has to be a easyier way, a managed .Net way. anyways thanks for your time. The Code Project Is Your Friend...
There is currently no "managed .Net way" of doing this, no. You need to implement system hooks by P/Invoking the necessary APIs. In fact, much of the .NET Framework BCL - especially System.Windows.Forms.dll - encapsulates native functionality already. You can see this by examing the BCL assemblies in the IL Disassembler (ildasm.exe that ships with the SDK) or another disassembler/decompiler of your liking. Read Global System Hooks in .NET[^]. Be very careful, however. System hooks need to be fast since all messages from a particular class of messages are passed through the hook. Some people writing managed code often take for granted what's given to you for free without thinking (or knowing) about the code that provides such functionality. And always make sure that your code will not currupt the system message pump unnecessarily. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]