Example #1
0
 private void KeyHook(KeyHookData data)
 {
     if (nowTopMost_ON_Setting)
     {
         topMost_ON_textBox.Text = data.ToString();
     }
     else if (nowTopMost_OFF_Setting)
     {
         topMost_OFF_textBox.Text = data.ToString();
     }
 }
Example #2
0
        public static KeyHookData Parse(string raw)
        {
            KeyHookData ret = new KeyHookData()
            {
                key = VirtualKeys.Unknown, shiftDown = false, ctrlDown = false
            };

            string[] arr = raw.Split('+');

            foreach (string str in arr)
            {
                VirtualKeys key;
                if (Enum.TryParse(str, out key))
                {
                    switch (key)
                    {
                    case VirtualKeys.Control:
                        ret.ctrlDown = true;
                        break;

                    case VirtualKeys.LeftShift:
                        ret.shiftDown = true;
                        break;

                    default:
                        ret.key = key;
                        break;
                    }
                }
                else
                {
                    throw new Exception("설정에서 키를 불러오는 과정에서 예외가 발생하였습니다.");
                }
            }

            if (ret.key == VirtualKeys.Unknown)
            {
                if (ret.shiftDown)
                {
                    ret.key = VirtualKeys.LeftShift;
                }
                else if (ret.ctrlDown)
                {
                    ret.key = VirtualKeys.Control;
                }
            }

            return(ret);
        }
Example #3
0
        private void KeyHook(KeyHookData data)
        {
            if (MainContext.Get.IsBlockingKeyInput)
            {
                return;
            }

            KeyHookData on  = KeyHookData.Parse(Settings.Default.TopMost_ON);
            KeyHookData off = KeyHookData.Parse(Settings.Default.TopMost_OFF);

            if (on.ctrlDown == data.ctrlDown && on.shiftDown == data.shiftDown && on.key == data.key)
            {
                SetWindowPos(GetForegroundWindow(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
                MainContext.Get.ShowMessage("TopMost ON!\r\n(Always on Top을 종료해도 TopMost는 유지됩니다.)");
            }
            else if (off.ctrlDown == data.ctrlDown && off.shiftDown == data.shiftDown && off.key == data.key)
            {
                SetWindowPos(GetForegroundWindow(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
                MainContext.Get.ShowMessage("TopMost OFF!");
            }
        }