Beispiel #1
0
        /// <summary>
        /// 키보드 프로시저 처리하기
        /// </summary>
        /// <param name="code">코드</param>
        /// <param name="wordParameter">WORD 매개 변수</param>
        /// <param name="longParameter">LONG 매개 변수</param>
        /// <returns>처리 결과</returns>
        private static IntPtr KeyboardProc(int code, IntPtr wordParameter, IntPtr longParameter)
        {
            if (code == WIN32Helper.HC_ACTION)
            {
                uint wordParameterValue = (uint)wordParameter;
                long longParamererValue = (long)longParameter;

                if (wordParameterValue == 256)
                {
                    KEYBOARDHOOKSTRUCT keyboardHookStructure = (KEYBOARDHOOKSTRUCT)Marshal.PtrToStructure
                                                               (
                        longParameter,
                        typeof(KEYBOARDHOOKSTRUCT)
                                                               );

                    KeyClick?.Invoke(keyboardHookStructure.VirtualKeyCode);
                }

                if ((wordParameterValue == 229 && longParamererValue == -2147483647) || (wordParameterValue == 229 && longParamererValue == -2147483648))
                {
                    if (IsHookingArea())
                    {
                        return((IntPtr)1);
                    }
                }
            }

            return(WIN32Helper.CallNextHookEx(_keyboardHookHandle, code, wordParameter, longParameter));
        }
Beispiel #2
0
 public void Start()
 {
     Console.WriteLine("Running!");
     while (true)
     {
         char charKey = Console.ReadKey(true).KeyChar;
         //if (KeyClick != null)
         //{
         //    KeyClick(charKey);
         //}
         if (charKey == 'q')
         {
             //KeyClick?.Invoke(charKey);
             break;
         }
         KeyClick?.Invoke(charKey);
     }
 }
 public void OnKeyClick(KeyClickEventArgs e)
 {
     KeyClick?.Invoke(this, e);
 }
Beispiel #4
0
 private void KeyDown_MouseDown(object sender, MouseEventArgs e)
 {
     if (sender is Label lbl)
     {
         if (string.IsNullOrEmpty(lbl.Text))
         {
             return;
         }
         //切换大写
         if (lbl.Text == "CAP")
         {
             ToUpperOrLower(this, true);
             lbl.Text = "cap";
         }
         //切换小写
         else if (lbl.Text == "cap")
         {
             ToUpperOrLower(this, false);
             lbl.Text = "CAP";
         }
         //切换字符或数字
         else if (lbl.Text == "?123" || lbl.Text == "abc.")
         {
             ChangeShow(this);
         }
         else if (lbl.Text == "空格")
         {
             SendKeys.Send(" ");
         }
         else if (lbl.Text.ToLower() == "shift")
         {
             SendKeys.Send("+");
             if (lbl.Text == "shift")
             {
                 lbl.Text = "SHIFT";
             }
             else
             {
                 lbl.Text = "shift";
             }
         }
         else if (lbl.Text == "删除")
         {
             SendKeys.Send("{BACKSPACE}");
             BackspaceClick?.Invoke(sender, e);
         }
         else if (lbl.Text == "回车")
         {
             SendKeys.Send("{ENTER}");
             EnterClick?.Invoke(sender, e);
         }
         else if (lbl.Text == "关闭")
         {
             CloseClick?.Invoke(this, e);
         }
         else
         {
             string str = "{" + lbl.Text + "}";
             SendKeys.Send(str);
             KeyClick?.Invoke(sender, e);
         }
     }
 }