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)); }
private IntPtr captureKey(int nCode, IntPtr wp, IntPtr lp) { //using (StreamWriter sw = File.AppendText("keys.log")) //{ //sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " nCode=" + nCode); if (nCode >= 0) //(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()); //sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " key=" + (int)theKey.Key + " code=" + theKey.Code + " flags=" + theKey.flags + " extra=" + theKey.extra); if (hotKeys && ((IList <Keys>)catchKeys).Contains(theKey.Key)) { if (theKey.flags < 128 && currentKey != theKey.Key) { TimerReset(); currentKey = theKey.Key; UpdateMem(); TimerHoldKey.Start(); } else if (theKey.flags >= 128) { TimerReset(); currentKey = Keys.None; SaveSettings(); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// } return(CallNextHookEx(ptrHook, nCode, wp, lp)); //} }