Ejemplo n.º 1
0
        protected override void WndProc(ref Message message)
        {
            switch (message.Msg)
            {
            case HotKeyHelper.WM_HOTKEY:
            {
                Keys key = (Keys)(((int)message.LParam >> 16) & 0xFFFF);
                HotKeyHelper.KeyModifiers modifier = (HotKeyHelper.KeyModifiers)((int)message.LParam & 0xFFFF);

                if (keysTextBox시작_키.Focused)
                {
                    keysTextBox시작_키.SelectedKeys = key | KeysHelper.CovertToHotKeyModifiersForHelpers(modifier);
                    break;
                }

                if (keysTextBox종료_키.Focused)
                {
                    keysTextBox종료_키.SelectedKeys = key | KeysHelper.CovertToHotKeyModifiersForHelpers(modifier);
                    break;
                }

                var startKeys      = KeysHelper.ClearModifiers(keysTextBox시작_키.SelectedKeys);
                var startModifiers = KeysHelper.CovertToHotKeyModifiers(keysTextBox시작_키.SelectedKeys);

                var endKeys      = KeysHelper.ClearModifiers(keysTextBox종료_키.SelectedKeys);
                var endModifiers = KeysHelper.CovertToHotKeyModifiers(keysTextBox종료_키.SelectedKeys);

                //if ((HotKeyHelper.KeyModifiers.Control | HotKeyHelper.KeyModifiers.Shift) == modifier && Keys.N == key)
                //if ((HotKeyHelper.KeyModifiers.None) == modifier && Keys.F4 == key)
                if (startModifiers == modifier &&
                    startKeys == key)
                {
                    // 시작 키, 종료 키가 같을 경우에는 토글
                    if (startKeys == endKeys &&
                        startModifiers == endModifiers)
                    {
                        ToggleMacro();
                    }
                    else
                    {
                        StartMacro();
                    }
                }
                else if (endModifiers == modifier &&
                         endKeys == key)
                {
                    EndMacro();
                }
            }
            break;
            }
            base.WndProc(ref message);
        }