Hook KeyPress Event in C#
I am reading few articles that explains hooking a key pressed by using globalKeyBoardHook() but didn't 开发者_开发问答told where this dll is. How to get this class available. Please help how to get this dll. Is it a windows dll api or an external dll. ?
Currently I am reading this, this article and not getting anything.
Can anyone explain all the terms used in the line below. It seems that we are importing a dll. But why like this since we can add dll by right clicking on refrences folder. Any reason
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
The globalKeyBoardHook
class is just a class created by the author of the code project article you read here. If you look at that link you'll see a link called something like Download source - 29.62 KB. Try clicking on that link, downloading the file and inside there there'll be a globalKeyboardHook.cs file that you should add to your project.
That code will then call SetWindowsHookEx
from user32.dll
, but you don't really need to worry about that.
All in all, read through that article carefully, I think you might have missed some steps in how to use his code.
Look in the GAC for these dlls. Visual Studio should automatically handle the references for you.
Related Q&A on Global Hook
精彩评论