Beispiel #1
0
 bool OnKeyHook(int code, WM wParam, KBDLLHOOKSTRUCT lParam, Hooker hooker)
 {
     if (lParam.vkCode ==  44 && wParam == WM.KEYUP)
     {
         takeScreenshot();
     }
     return false;
 }
Beispiel #2
0
 void UpdateSysKeyStates(WM wParam, ref KBDLLHOOKSTRUCT lParam)
 {
     switch (wParam)
     {
         case WM.KEYDOWN:
         case WM.SYSKEYDOWN:
             if (lParam.vkCode == 160 || lParam.vkCode == 161) onShift = true;
             if (lParam.vkCode == 162 || lParam.vkCode == 163) onCtrl = true;
             if (lParam.vkCode == 164 || lParam.vkCode == 165) onAlt = true;
             break;
         case WM.KEYUP:
         case WM.SYSKEYUP:
             if (lParam.vkCode == 160 || lParam.vkCode == 161) onShift = false;
             if (lParam.vkCode == 162 || lParam.vkCode == 163) onCtrl = false;
             if (lParam.vkCode == 164 || lParam.vkCode == 165) onAlt = false;
             break;
     }
 }
Beispiel #3
0
 static extern int CallNextHookEx(int hook, int code, WM wParam, ref KBDLLHOOKSTRUCT lParam);
Beispiel #4
0
 /// <summary>
 /// キーのフック処理
 /// </summary>
 /// <param name="code"></param>
 /// <param name="wParam"></param>
 /// <param name="lParam"></param>
 /// <returns>ignore CallNextHookEx() or not</returns>
 int OnKeyLLHook(int code, WM wParam, ref KBDLLHOOKSTRUCT lParam)
 {
     UpdateSysKeyStates(wParam, ref lParam);
     bool ignore = false;
     if (OnKeyHook != null)
     {
         ignore = OnKeyHook(code, wParam, lParam, this);
     }
     return ignore ? 1 : CallNextHookEx(0, code, wParam, ref lParam);
 }