During the idle time, I learned the keyboard hook and used the C # language to design and implement it. below is the class diagram I designed:
There are two types of keyboard hooks: Global hooks and private hooks. Here I will design them in two categories:
Public delegate int HOOKPROC (int nCode, int wParam, int lParam );
Public enum HookType
{
WH_KEYBOARD = 2, // Private Hook
WH_KEYBOARD_LL = 13 // global hook
}
Hook base class implementation Public abstract class hook
{
// Set the hook
[DllImport ("user32.dll", CharSet = CharSet. Auto, CallingConvention = CallingConvention. StdCall)]
Public static extern int SetWindowsHookEx (HookType idHook, HOOKPROC lpfn, IntPtr hInstance, int threadId );
// Hook Extraction
[DllImport ("user32.dll", CharSet = CharSet. Auto, CallingConvention = CallingConvention. StdCall)]
Public static extern bool UnhookWindowsHookEx (int idHook );
[DllImport ("kernel32")]
Public static extern int GetCurrentThreadId ();
/// <Summary>
/// Hook handling delegate
/// </Summary>
Public HOOKPROC proc;
/// <Summary>
/// Hook type
/// </Summary>
Public & n