Ejemplo n.º 1
0
 public int hookProc(int code, int wParam, ref globalKeyboardHook.keyboardHookStruct lParam)
 {
     if (code >= 0)
     {
         KeyEventArgs keyEventArg = new KeyEventArgs((Keys)lParam.vkCode);
         this.lastKey = lParam;
         if ((wParam == 256 || wParam == 260) && (this.KeyDown != null || this.KeyPress != null))
         {
             if (this.KeyDown != null)
             {
                 this.KeyDown.Raise(this, keyEventArg);
             }
             if (this.KeyPress != null)
             {
                 this.KeyPress.Raise(this, keyEventArg);
             }
         }
         else if ((wParam == 257 || wParam == 261) && this.KeyUp != null)
         {
             this.KeyUp.Raise(this, keyEventArg);
         }
         if (keyEventArg.Handled)
         {
             return(1);
         }
     }
     return(globalKeyboardHook.CallNextHookEx(this.hhook, code, wParam, ref lParam));
 }
Ejemplo n.º 2
0
        public string GetKeyText(ref globalKeyboardHook.keyboardHookStruct lParam)
        {
            StringBuilder lpString = new StringBuilder(128);
            string        str;

            if (lParam.scanCode >= 2 && lParam.scanCode <= 11)
            {
                str = ((lParam.scanCode - 1) % 10).ToString();
            }
            else
            {
                globalKeyboardHook.GetKeyNameText((uint)(1 + (lParam.scanCode << 16) + (lParam.flags << 24)), lpString, 128);
                str = lpString.ToString();
                if (str == "" && lParam.vkCode == 161 && lParam.scanCode == 54)
                {
                    str = "SHIFT";
                }
            }
            return(str);
        }
Ejemplo n.º 3
0
        public string GetKeyText(ref globalKeyboardHook.keyboardHookStruct lParam)
        {
            StringBuilder stringBuilder = new StringBuilder(128);
            string        text;

            if (lParam.scanCode >= 2 && lParam.scanCode <= 11)
            {
                text = ((lParam.scanCode - 1) % 10).ToString();
            }
            else
            {
                globalKeyboardHook.GetKeyNameText((uint)(1 + (lParam.scanCode << 16) + (lParam.flags << 24)), stringBuilder, 128);
                text = stringBuilder.ToString();
                if (text == "" && lParam.vkCode == 161 && lParam.scanCode == 54)
                {
                    text = "SHIFT";
                }
            }
            return(text);
        }
Ejemplo n.º 4
0
        public string GetKeyText(ref globalKeyboardHook.keyboardHookStruct lParam)
        {
            string        str           = "";
            StringBuilder stringBuilder = new StringBuilder(128);

            if (lParam.scanCode < 2 || lParam.scanCode > 11)
            {
                globalKeyboardHook.GetKeyNameText((uint)(1 + (lParam.scanCode << 16) + (lParam.flags << 24)), stringBuilder, 128);
                str = stringBuilder.ToString();
                if (str == "" && lParam.vkCode == 161 && lParam.scanCode == 54)
                {
                    str = "SHIFT";
                }
            }
            else
            {
                int num = (lParam.scanCode - 1) % 10;
                str = num.ToString();
            }
            return(str);
        }
Ejemplo n.º 5
0
 public int hookProc(int code, int wParam, ref globalKeyboardHook.keyboardHookStruct lParam)
 {
     if (code >= 0)
     {
         KeyEventArgs args = new KeyEventArgs((Keys)lParam.vkCode);
         this.lastKey = lParam;
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated field
         if ((wParam == 256 || wParam == 260) && (this.KeyDown != null || this.KeyPress != null))
         {
             // ISSUE: reference to a compiler-generated field
             if (this.KeyDown != null)
             {
                 // ISSUE: reference to a compiler-generated field
                 this.KeyDown.Raise((object)this, args);
             }
             // ISSUE: reference to a compiler-generated field
             if (this.KeyPress != null)
             {
                 // ISSUE: reference to a compiler-generated field
                 this.KeyPress.Raise((object)this, args);
             }
         }
         else
         {
             // ISSUE: reference to a compiler-generated field
             if ((wParam == 257 || wParam == 261) && this.KeyUp != null)
             {
                 // ISSUE: reference to a compiler-generated field
                 this.KeyUp.Raise((object)this, args);
             }
         }
         if (args.Handled)
         {
             return(1);
         }
     }
     return(globalKeyboardHook.CallNextHookEx(this.hhook, code, wParam, ref lParam));
 }
Ejemplo n.º 6
0
 private static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref globalKeyboardHook.keyboardHookStruct lParam);