Exemple #1
0
        private void txtHotkey_KeyDown(object sender, KeyEventArgs e)
        {
            e.SuppressKeyPress = true;
            // Don't want to do anything if only a modifier key is pressed.
            //     Modifiers                                 Asian keys (kana, hanja, kanji etc)       IME related keys (convert etc)           Korean alt (process)  Windows keys
            if (!((e.KeyValue >= 16 && e.KeyValue <= 18) || (e.KeyValue >= 21 && e.KeyValue <= 25) || (e.KeyValue >= 28 && e.KeyValue <= 31) || e.KeyValue == 229 || (e.KeyValue >= 91 && e.KeyValue <= 92)))
            {
                Win32.UnregisterHotKey(this.Handle, (int)hotkey);
                hotkey = e.KeyData;
                // Extract modifiers
                hotkeyModifiers = 0;
                if ((e.Modifiers & Keys.Shift) != 0)
                {
                    hotkeyModifiers |= Win32.fsModifiers.Shift;
                }
                if ((e.Modifiers & Keys.Control) != 0)
                {
                    hotkeyModifiers |= Win32.fsModifiers.Control;
                }
                if ((e.Modifiers & Keys.Alt) != 0)
                {
                    hotkeyModifiers |= Win32.fsModifiers.Alt;
                }

                SetHotkey();
            }
        }
Exemple #2
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == Win32.WM_HOTKEY)
            {
                // Ignore the hotkey if the user is editing it.
                if (txtHotkey.Focused)
                {
                    return;
                }

                Win32.fsModifiers modifiers = (Win32.fsModifiers)((int)m.LParam & 0xFFFF);
                Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                if (key == (hotkey & Keys.KeyCode) && modifiers == hotkeyModifiers)
                {
                    btnToggle_Click(null, null);
                }
            }
        }
Exemple #3
0
        private void LoadSettings()
        {
            if (File.Exists(settingsFilePath))
            {
                using (FileStream fs = File.Open(settingsFilePath, FileMode.Open))
                {
                    using (BinaryReader r = new BinaryReader(fs))
                    {
                        byte buttonType = r.ReadByte();

                        byte locationType = r.ReadByte();
                        int  fixedX       = r.ReadInt32();
                        int  fixedY       = r.ReadInt32();
                        int  randomX      = r.ReadInt32();
                        int  randomY      = r.ReadInt32();
                        int  randomWidth  = r.ReadInt32();
                        int  randomHeight = r.ReadInt32();

                        byte delayType     = r.ReadByte();
                        int  fixedDelay    = r.ReadInt32();
                        int  rangeDelayMin = r.ReadInt32();
                        int  rangeDelayMax = r.ReadInt32();

                        byte countType = r.ReadByte();
                        int  count     = r.ReadInt32();

                        hotkey = (Keys)r.ReadInt32();

                        switch (buttonType)
                        {
                        case 1:
                            rdbClickSingleLeft.Checked = true;
                            break;

                        case 2:
                            rdbClickSingleMiddle.Checked = true;
                            break;

                        case 3:
                            rdbClickSingleRight.Checked = true;
                            break;

                        case 4:
                            rdbClickDoubleLeft.Checked = true;
                            break;

                        case 5:
                            rdbClickDoubleMiddle.Checked = true;
                            break;

                        case 6:
                            rdbClickDoubleRight.Checked = true;
                            break;
                        }

                        switch (locationType)
                        {
                        case 1:
                            rdbLocationFixed.Checked = true;
                            break;

                        case 2:
                            rdbLocationMouse.Checked = true;
                            break;

                        case 3:
                            rdbLocationRandom.Checked = true;
                            break;

                        case 4:
                            rdbLocationRandomArea.Checked = true;
                            break;
                        }

                        numFixedX.Value       = fixedX;
                        numFixedY.Value       = fixedY;
                        numRandomX.Value      = randomX;
                        numRandomY.Value      = randomY;
                        numRandomWidth.Value  = randomWidth;
                        numRandomHeight.Value = randomHeight;

                        switch (delayType)
                        {
                        case 1:
                            rdbDelayFixed.Checked = true;
                            break;

                        case 2:
                            rdbDelayRange.Checked = true;
                            break;
                        }

                        numDelayFixed.Value    = fixedDelay;
                        numDelayRangeMin.Value = rangeDelayMin;
                        numDelayRangeMax.Value = rangeDelayMax;

                        switch (countType)
                        {
                        case 1:
                            rdbCount.Checked = true;
                            break;

                        case 2:
                            rdbUntilStopped.Checked = true;
                            break;
                        }

                        numCount.Value = count;

                        if (hotkey != Keys.None)
                        {
                            var hotkeyMods = hotkey & Keys.Modifiers;
                            this.hotkeyModifiers = 0;
                            if ((hotkeyMods & Keys.Shift) != 0)
                            {
                                this.hotkeyModifiers |= Win32.fsModifiers.Shift;
                            }
                            if ((hotkeyMods & Keys.Control) != 0)
                            {
                                this.hotkeyModifiers |= Win32.fsModifiers.Control;
                            }
                            if ((hotkeyMods & Keys.Alt) != 0)
                            {
                                this.hotkeyModifiers |= Win32.fsModifiers.Alt;
                            }

                            SetHotkey();
                        }
                    }
                }
            }
        }
Exemple #4
0
        private void LoadSettings()
        {
            if (File.Exists("settings.dat"))
            {
                using (FileStream fs = File.Open("settings.dat", FileMode.Open))
                {
                    using (BinaryReader r = new BinaryReader(fs))
                    {
                        byte buttonType = r.ReadByte();
                        int  fixedDelay = r.ReadInt32();

                        byte countType = r.ReadByte();
                        int  count     = r.ReadInt32();

                        hotkey = (Keys)r.ReadInt32();

                        // 确定点击类型的显示
                        switch (buttonType)
                        {
                        case 1:
                            rdbClickSingleLeft.Checked = true;
                            break;

                        case 2:
                            rdbClickSingleMiddle.Checked = true;
                            break;

                        case 3:
                            rdbClickSingleRight.Checked = true;
                            break;

                        case 4:
                            rdbClickDoubleLeft.Checked = true;
                            break;

                        case 5:
                            rdbClickDoubleMiddle.Checked = true;
                            break;

                        case 6:
                            rdbClickDoubleRight.Checked = true;
                            break;
                        }

                        numDelayFixed.Value = fixedDelay;

                        switch (countType)
                        {
                        case 1:
                            rdbCount.Checked = true;
                            break;

                        case 2:
                            rdbUntilStopped.Checked = true;
                            break;
                        }

                        numCount.Value = count;

                        if (hotkey != Keys.None)
                        {
                            var hotkeyModifiers = hotkey & Keys.Modifiers;
                            hotkeyNodifiers = 0;
                            if ((hotkeyModifiers & Keys.Shift) != 0)
                            {
                                hotkeyNodifiers |= Win32.fsModifiers.Shift;
                            }
                            if ((hotkeyModifiers & Keys.Control) != 0)
                            {
                                hotkeyNodifiers |= Win32.fsModifiers.Control;
                            }
                            if ((hotkeyModifiers & Keys.Alt) != 0)
                            {
                                hotkeyNodifiers |= Win32.fsModifiers.Alt;
                            }

                            SetHotkey();
                        }
                    }
                }
            }
        }
Exemple #5
0
        private void txtHotkey_KeyDown(object sender, KeyEventArgs e)
        {
            e.SuppressKeyPress = true;
            // Don't want to do anything if only a modifier key is pressed.
            //     Modifiers                                 Asian keys (kana, hanja, kanji etc)       IME related keys (convert etc)           Korean alt (process)  Windows keys
            if (!((e.KeyValue >= 16 && e.KeyValue <= 18) || (e.KeyValue >= 21 && e.KeyValue <= 25) || (e.KeyValue >= 28 && e.KeyValue <= 31) || e.KeyValue == 229 || (e.KeyValue >= 91 && e.KeyValue <= 92)))
            {
                Win32.UnregisterHotKey(this.Handle, (int)hotkey);
                hotkey = e.KeyData;
                // Extract modifiers
                hotkeyNodifiers = 0;
                if ((e.Modifiers & Keys.Shift) != 0)
                {
                    hotkeyNodifiers |= Win32.fsModifiers.Shift;
                }
                if ((e.Modifiers & Keys.Control) != 0)
                {
                    hotkeyNodifiers |= Win32.fsModifiers.Control;
                }
                if ((e.Modifiers & Keys.Alt) != 0)
                {
                    hotkeyNodifiers |= Win32.fsModifiers.Alt;
                }

                SetHotkey();
            }
        }
Exemple #6
0
        private void LoadSettings()
        {
            if (File.Exists("settings.dat"))
            {
                using (FileStream fs = File.Open("settings.dat", FileMode.Open))
                {
                    using (BinaryReader r = new BinaryReader(fs))
                    {
                        byte buttonType = r.ReadByte();

                        byte locationType = r.ReadByte();
                        int fixedX = r.ReadInt32();
                        int fixedY = r.ReadInt32();
                        int randomX = r.ReadInt32();
                        int randomY = r.ReadInt32();
                        int randomWidth = r.ReadInt32();
                        int randomHeight = r.ReadInt32();

                        byte delayType = r.ReadByte();
                        int fixedDelay = r.ReadInt32();
                        int rangeDelayMin = r.ReadInt32();
                        int rangeDelayMax = r.ReadInt32();

                        byte countType = r.ReadByte();
                        int count = r.ReadInt32();

                        hotkey = (Keys)r.ReadInt32();

                        switch (buttonType)
                        {
                            case 1:
                                rdbClickSingleLeft.Checked = true;
                                break;
                            case 2:
                                rdbClickSingleMiddle.Checked = true;
                                break;
                            case 3:
                                rdbClickSingleRight.Checked = true;
                                break;
                            case 4:
                                rdbClickDoubleLeft.Checked = true;
                                break;
                            case 5:
                                rdbClickDoubleMiddle.Checked = true;
                                break;
                            case 6:
                                rdbClickDoubleRight.Checked = true;
                                break;
                        }

                        switch (locationType)
                        {
                            case 1:
                                rdbLocationFixed.Checked = true;
                                break;
                            case 2:
                                rdbLocationMouse.Checked = true;
                                break;
                            case 3:
                                rdbLocationRandom.Checked = true;
                                break;
                            case 4:
                                rdbLocationRandomArea.Checked = true;
                                break;
                        }

                        numFixedX.Value = fixedX;
                        numFixedY.Value = fixedY;
                        numRandomX.Value = randomX;
                        numRandomY.Value = randomY;
                        numRandomWidth.Value = randomWidth;
                        numRandomHeight.Value = randomHeight;

                        switch (delayType)
                        {
                            case 1:
                                rdbDelayFixed.Checked = true;
                                break;
                            case 2:
                                rdbDelayRange.Checked = true;
                                break;
                        }

                        numDelayFixed.Value = fixedDelay;
                        numDelayRangeMin.Value = rangeDelayMin;
                        numDelayRangeMax.Value = rangeDelayMax;

                        switch (countType)
                        {
                            case 1:
                                rdbCount.Checked = true;
                                break;
                            case 2:
                                rdbUntilStopped.Checked = true;
                                break;
                        }

                        numCount.Value = count;

                        if (hotkey != Keys.None)
                        {
                            var hotkeyModifiers = hotkey & Keys.Modifiers;
                            hotkeyNodifiers = 0;
                            if ((hotkeyModifiers & Keys.Shift) != 0)
                            {
                                hotkeyNodifiers |= Win32.fsModifiers.Shift;
                            }
                            if ((hotkeyModifiers & Keys.Control) != 0)
                            {
                                hotkeyNodifiers |= Win32.fsModifiers.Control;
                            }
                            if ((hotkeyModifiers & Keys.Alt) != 0)
                            {
                                hotkeyNodifiers |= Win32.fsModifiers.Alt;
                            }

                            SetHotkey();
                        }
                    }
                }
            }
        }