예제 #1
0
        private IntPtr captureKey(int nCode, IntPtr wp, IntPtr lp)
        {
            if (proc != null && nCode >= 0)
            {
                theKey = (KeyHook)Marshal.PtrToStructure(lp, typeof(KeyHook));
                // Keyboard Hook Time /////////////////////////////////////////////////////////////////////////////////////////

                //if (theKey.flags < 128) MessageBox.Show(theKey.key.ToString() + "\n" + ((int)theKey.key).ToString());

                if (((IList <Keys>)catchKeys).Contains(theKey.Key) && hotKeys)
                {
                    if (theKey.flags < 128 && currentKey != theKey.Key)
                    {
                        TimerReset();
                        currentKey = theKey.Key;
                        UpdateMem();
                        TimerHoldKey.Start();
                    }
                    else if (theKey.flags >= 128)
                    {
                        TimerReset();
                        currentKey = Keys.None;
                        SaveData();
                    }
                }

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            return(CallNextHookEx(ptrHook, nCode, wp, lp));
        }
예제 #2
0
        private IntPtr captureKey(int nCode, IntPtr wp, IntPtr lp)
        {
            if (nCode >= 0)
            {
                theKey = (KeyHook)Marshal.PtrToStructure(lp, typeof(KeyHook));
                // Keyboard Hook Time /////////////////////////////////////////////////////////////////////////////////////////

                if (theKey.flags < 128 && (int)theKey.Key != (int)Keys.Return)
                {
                    _pressedKey = theKey.Key;

                    _pressedKeyName = MainForm.VirtualKeyName(_pressedKey);

                    lblKeyName.Text    = _pressedKeyName; //+ " " + _pressedKey.ToString(); //+ " " + nonVirtualKey; //MainForm.KeyName(theKey.Key)
                    btnAccept.Enabled  = true;
                    this.ActiveControl = btnAccept;
                }

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            return(CallNextHookEx(ptrHook, nCode, wp, lp));
        }