Esempio n. 1
0
        private ModKeys GetModKey()
        {
            ModKeys modkey = ModKeys.None;

            if (chkAlt.Checked)
            {
                modkey = modkey | ModKeys.Alt;
            }

            if (chkCtrl.Checked)
            {
                modkey = modkey | ModKeys.Control;
            }

            if (chkShift.Checked)
            {
                modkey = modkey | ModKeys.Shift;
            }

            if (chkWin.Checked)
            {
                modkey = modkey | ModKeys.Win;
            }

            return(modkey);
        }
Esempio n. 2
0
        public static string GenerateHotKeyMeassage(ModKeys modkey, Keys key)
        {
            string mes = "";

            //if ((modkey & ModKeys.None) == ModKeys.None) return mes;

            if ((modkey & ModKeys.Alt) == ModKeys.Alt)
            {
                mes += "Alt + ";
            }

            if ((modkey & ModKeys.Control) == ModKeys.Control)
            {
                mes += "Control + ";
            }

            if ((modkey & ModKeys.Shift) == ModKeys.Shift)
            {
                mes += "Shift + ";
            }

            if ((modkey & ModKeys.Win) == ModKeys.Win)
            {
                mes += "Win + ";
            }

            mes += key.ToString();

            return(mes);
        }
Esempio n. 3
0
        public bool OnKeyDown(ModKeys modKeys, Keys keyCode, string srcElementTagName)
        {
            var args = new HotKeyDownEventArgs(modKeys, keyCode, srcElementTagName);

            KeyDown?.Invoke(null, args);
            return(args.PreventDefault);
        }
 /// <summary>
 /// Initialize a new instance of the HotKeyDownEventArgs class.
 /// </summary>
 public HotKeyDownEventArgs(ModKeys modKeys, Keys keyCode, string srcElementTagName, string srcElementTypeAttribute)
 {
     ModKeys                 = modKeys;
     Key                     = keyCode;
     SrcElementTagName       = srcElementTagName;
     SrcElementTypeAttribute = srcElementTypeAttribute;
 }
Esempio n. 5
0
 public EnteredKey(ModKeys modKeys, string keyName, string key = "", string code = "")
 {
     ModKeys = modKeys;
     KeyName = keyName;
     Key     = key;
     Code    = code;
 }
Esempio n. 6
0
 /// <summary>
 /// Add a new hotkey entry to this context.<br/>
 /// if the key that you want to hook is not covered by the Keys enum values, use this overload version that accepts key name as a string.
 /// </summary>
 /// <param name="modKeys">The combination of modifier keys flags.</param>
 /// <param name="keyName">The name of the identifier of hotkey.<para>The "key name" is a bit different from the "key" and "code" properties of the DOM event object.<br/> The "key name" comes from "key" and "code", but it is tried to converting to one of the Keys enum values names.<br/>if the keyboard event is not covered by Keys enum values, the "key name" will be the value of "code" or "key".</para></param>
 /// <param name="action">The callback action that will be invoked when user enter modKeys + key combination on the browser.</param>
 /// <param name="description">The description of the meaning of this hot key entry.</param>
 /// <param name="exclude">The combination of HTML element flags that will be not allowed hotkey works.</param>
 /// <returns>This context.</returns>
 public HotKeysContext Add(ModKeys modKeys, string keyName, Action action, string description = "", Exclude exclude = Exclude.Default)
 {
     if (!Enum.TryParse <Keys>(keyName, out var key))
     {
         throw new FormatException($"Unknown key name \"{keyName}\".");
     }
     return(this.Add(modKeys, key, action, description, exclude));
 }
Esempio n. 7
0
 /// <summary>
 /// Initialize a new instance of the HotKeyEntry class.
 /// </summary>
 /// <param name="modKeys">The combination of modifier keys flags.</param>
 /// <param name="key">The identifier of hotkey.</param>
 /// <param name="action">The callback action that will be invoked when user enter modKeys + key combination on the browser.</param>
 /// <param name="description">The description of the meaning of this hot key entry.</param>
 /// <param name="allowIn">The combination of HTML element flags that will be allowed hotkey works.</param>
 public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Func <HotKeyEntry, Task> action)
 {
     ModKeys     = modKeys;
     Key         = key;
     AllowIn     = allowIn;
     Description = description;
     Action      = action;
 }
Esempio n. 8
0
        public static void OnMouse(int button, int wheel)
        {
            if (World.Player == null || !m_Enabled)
            {
                return;
            }

            ModKeys cur = ModKeys.None;
            int     key = 0;

            switch (button)
            {
            case 0:
                if (wheel == 1)
                {
                    // Wheel down
                    key = -2;
                }
                else
                {
                    // Wheel up
                    key = -1;
                }
                break;

            case 1:
                key = -3;
                break;

            case 2:
                key = -4;
                break;

            case 3:
                key = -5;
                break;
            }

            if (KeyDown(Keys.ControlKey))
            {
                cur |= ModKeys.Control;
            }
            if (KeyDown(Keys.Menu))
            {
                cur |= ModKeys.Alt;
            }
            if (KeyDown(Keys.ShiftKey))
            {
                cur |= ModKeys.Shift;
            }

            KeyData hk = Get(key, cur);

            if (hk != null)
            {
                hk.Callback();
            }
        }
Esempio n. 9
0
 public HotKeyEntry(ModKeys modKeys, Keys key, Exclude exclude, string description, Func <HotKeyEntry, Task> action)
 {
     this.ModKeys     = modKeys;
     this.Key         = key;
     this.KeyName     = key.ToString();
     this.Exclude     = exclude;
     this.Description = description;
     this.Action      = action;
 }
Esempio n. 10
0
        /// <summary>
        /// コンストラクター
        /// </summary>
        /// <param name="hash">ハッシュ文字列</param>
        /// <param name="handle">ホットキーを登録するウインドウハンドル</param>
        /// <param name="modkey">登録するModKey列挙体の組み合わせ</param>
        /// <param name="key">登録するKeys列挙体</param>
        public HotKey(string hash, IntPtr handle, ModKeys modkey, Keys key)
        {
            Hash   = hash;
            Handle = handle;
            ModKey = modkey;
            Key    = key;

            SuccessRegisterHotKey = false;
        }
Esempio n. 11
0
 /// <summary>
 /// Add a new hotkey entry to this context.<br/>
 /// if the key that you want to hook is not covered by the Keys enum values, use the other overload version that accepts key name as a string.
 /// </summary>
 /// <param name="modKeys">The combination of modifier keys flags.</param>
 /// <param name="key">The identifier of hotkey.</param>
 /// <param name="action">The callback action that will be invoked when user enter modKeys + key combination on the browser.</param>
 /// <param name="description">The description of the meaning of this hot key entry.</param>
 /// <param name="exclude">The combination of HTML element flags that will be not allowed hotkey works.</param>
 /// <returns>This context.</returns>
 public HotKeysContext Add(ModKeys modKeys, Keys key, Action <HotKeyEntry> action, string description = "", Exclude exclude = Exclude.Default)
 {
     this.Keys.Add(this.Register(new HotKeyEntry(modKeys, key, exclude, description, args =>
     {
         action(args);
         return(Task.CompletedTask);
     })));
     return(this);
 }
Esempio n. 12
0
        public bool RegisterHotKey(string hash, IntPtr handle, ModKeys modkey, Keys key)
        {
            this.Handle = handle;
            this.Hash   = hash;
            this.ModKey = modkey;
            this.Key    = key;

            return(RegisterHotKey());
        }
Esempio n. 13
0
 public HotKeyEntry(ModKeys modKeys, string keyName, AllowIn allowIn, string description, Func <HotKeyEntry, Task> action)
 {
     this.ModKeys     = modKeys;
     this.Key         = Enum.TryParse <Keys>(keyName, ignoreCase: true, out var v) ? v : (Keys)0;
     this.KeyName     = keyName;
     this.Exclude     = AllowInToExclude(allowIn);
     this.Description = description;
     this.Action      = action;
 }
Esempio n. 14
0
 public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Func <HotKeyEntry, Task> action)
 {
     this.ModKeys     = modKeys;
     this.Key         = key;
     this.KeyName     = key.ToString();
     this.Exclude     = AllowInToExclude(allowIn);
     this.Description = description;
     this.Action      = action;
 }
Esempio n. 15
0
File: ModKeys.cs Progetto: Nucs/nlib
        /// <summary>
        /// Returns which side is this modifier.
        /// incase of both <see cref="ModKeys.RLKey"/> is returned.
        /// otherwise, the side is returned.
        /// </summary>
        /// <param name="mk">The modifier key</param>
        /// <returns></returns>
        public static ModKeys ExportSide(this ModKeys mk)
        {
            int side = ((int)mk & 0x03);

            if (side == 0x03 || side == 0) //is it both sides?
            {
                return(ModKeys.RLKey);
            }
            return((ModKeys)side); //let casting determine which.
        }
Esempio n. 16
0
 public virtual int Unregister(Keys key, ModKeys modifier) {
     var count = _registers.RemoveWhere(hk => hk.Key == key && hk.Modifiers == modifier);
     if (_registers.Count == 0 && IsHooked)
         try {
             IsHooked = Unhook();
         } catch (Exception e) {
             throw new Exception("Failed to perform unhook. see inner exception.", e);
         }
     return count;
 }
        /// <summary>
        /// Registers a hot key in the system.
        /// </summary>
        /// <param name="modifier">The modifiers that are associated with the hot key.</param>
        /// <param name="key">The key itself that is associated with the hot key.</param>
        public void RegisterHotKey(ModKeys modifier, Keys key)
        {
            // increment the counter.
            _currentId = _currentId + 1;

            // register the hot key.
            if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
            {
                throw new InvalidOperationException("Couldn’t register the hot key.");
            }
        }
Esempio n. 18
0
File: ModKeys.cs Progetto: Nucs/nlib
        /// <summary>
        /// Compares two <see cref="ModKeys"/>. Use this instead of == or .Equals!!
        /// </summary>
        public static bool Compare(this ModKeys mk, ModKeys to)
        {
            var mk_side = mk.ExportSide();
            var to_side = to.ExportSide();

            if (mk_side != ModKeys.RLKey && to_side != ModKeys.RLKey && mk_side != to_side)
            {
                return(false);
            }
            return(((int)mk & ~3) == ((int)to & ~3));  //compare with elimination of sides.
        }
Esempio n. 19
0
 public static KeyData Get(int key, ModKeys mod)
 {
     for (int i = 0; i < m_List.Count; i++)
     {
         KeyData hk = (KeyData)m_List[i];
         if (hk.Key == key && hk.Mod == mod && hk.Key != 0)
         {
             return(hk);
         }
     }
     return(null);
 }
Esempio n. 20
0
 protected override void WndProc(ref Message m)
 {
     base.WndProc(ref m);
     if (m.Msg == EventHandlerClass1.HandlerBuddy.int_0)
     {
         Keys    keys_    = (Keys)((int)m.LParam >> 16 & 65535);
         ModKeys modKeys_ = (ModKeys)((int)m.LParam & 65535);
         if (this.eventHandler_0 != null)
         {
             this.eventHandler_0(this, new EventArgs1(modKeys_, keys_));
         }
     }
 }
Esempio n. 21
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="key"></param>
 /// <param name="modifiers"></param>
 /// <param name="description"></param>
 /// <returns>If added successfully, returns the <see cref="Hotkey"/> that was created, otherwise null.</returns>
 public virtual Hotkey Register(Keys key, ModKeys modifiers, string description) {
     if (_registers.Any(hkk => string.Equals(hkk.Description, description) || (hkk.Modifiers == modifiers && hkk.Key == key)))
         return null;
     Hotkey hk = Hotkey.Create(key, modifiers, description);
     _registers.Add(hk);
     if (IsHooked == false)
         try {
             IsHooked = Hook();
         } catch (Exception e) {
             throw new Exception("Failed to perform hook. see inner exception.", e);
         }
    return hk;
 }
Esempio n. 22
0
        public static bool OnKeyDown(int key)
        {
            if (World.Player == null)
            {
                return(true);
            }

            ModKeys cur = ModKeys.None;

            if (KeyDown(Keys.ControlKey))
            {
                cur |= ModKeys.Control;
            }
            if (KeyDown(Keys.Menu))
            {
                cur |= ModKeys.Alt;
            }
            if (KeyDown(Keys.ShiftKey))
            {
                cur |= ModKeys.Shift;
            }

            if (m_HK_En != null && m_HK_En.Key > 0 && m_HK_En.Mod == cur && (m_HK_En.Key == key || KeyDown((Keys)m_HK_En.Key)))
            {
                m_HK_En.Callback();
                return(m_HK_En.SendToUO);
            }

            if (m_Enabled)
            {
                for (int i = 0; i < m_List.Count; i++)
                {
                    KeyData hk = (KeyData)m_List[i];
                    if (hk.Mod == cur && hk.Key > 0)
                    {
                        if (hk.Key == key || KeyDown((Keys)hk.Key))
                        {
                            if (Macros.MacroManager.AcceptActions)
                            {
                                Macros.MacroManager.Action(new Macros.HotKeyAction(hk));
                            }
                            hk.Callback();
                            return(hk.SendToUO);
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 23
0
        public virtual int Unregister(Keys key, ModKeys modifier)
        {
            var count = _registers.RemoveWhere(hk => hk.Key == key && hk.Modifiers == modifier);

            if (_registers.Count == 0 && IsHooked)
            {
                try {
                    IsHooked = Unhook();
                } catch (Exception e) {
                    throw new Exception("Failed to perform unhook. see inner exception.", e);
                }
            }
            return(count);
        }
Esempio n. 24
0
        //
        /// <summary>
        /// Make the keycode strings more generic, eg LeftControl => Ctrl, Alpha1 => 1
        /// </summary>
        /// <param name="keyCode">The keycode to use</param>
        private string ReplaceString(KeyCode keyCode)
        {
            string keyCodeString = keyCode.ToString();

            if (ModKeys.Contains(keyCode))
            {
                // Replacements for mod keys
                return(keyCodeString.Replace("Left", "").Replace("Right", "").Replace("Control", "Ctrl").Replace("Command", "Cmd"));
            }
            else
            {
                // Replacement for all other keys
                return(keyCodeString.Replace("Alpha", "").Replace("Numpad", "Numpad "));
            }
        }
Esempio n. 25
0
        static void keydownText(object s, KeyEventArgs e)
        {
            MainWindow.label.Text = e.KeyValue.ToString();
            if (e.Control)
            {
                MainWindow.mkeys = ModKeys.Ctrl;
            }
            else
            {
                MainWindow.mkeys = ModKeys.Nok;
            }
            ctrl = e.Shift;

            //e.SuppressKeyPress
            //e.Handled = true;
        }
Esempio n. 26
0
        private bool OnHotKeyHandler(int key, int mod, bool ispressed)
        {
            if (ispressed && !Enum.IsDefined(typeof(SDL_Keycode_Ignore), key))
            {
                ModKeys cur = ModKeys.None;
                SDL_Keymod keymod = (SDL_Keymod) mod;
                if (keymod.HasFlag(SDL_Keymod.KMOD_LCTRL) || keymod.HasFlag(SDL_Keymod.KMOD_RCTRL))
                    cur |= ModKeys.Control;
                if (keymod.HasFlag(SDL_Keymod.KMOD_LALT) || keymod.HasFlag(SDL_Keymod.KMOD_RALT))
                    cur |= ModKeys.Alt;
                if (keymod.HasFlag(SDL_Keymod.KMOD_LSHIFT) || keymod.HasFlag(SDL_Keymod.KMOD_RSHIFT))
                    cur |= ModKeys.Shift;
                return HotKey.OnKeyDown(Win32Platform.MapKey(key), cur);
            }

            return true;
        }
            /// <summary>
            /// Overridden to get the notifications.
            /// </summary>
            /// <param name="m"></param>
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);

                // check if we got a hot key pressed.
                if (m.Msg == WM_HOTKEY)
                {
                    // get the keys.
                    Keys    key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                    ModKeys modifier = (ModKeys)((int)m.LParam & 0xFFFF);

                    // invoke the event to notify the parent.
                    if (KeyPressed != null)
                    {
                        KeyPressed(this, new KeyPressedEventArgs(modifier, key));
                    }
                }
            }
Esempio n. 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="modifiers"></param>
        /// <param name="description"></param>
        /// <returns>If added successfully, returns the <see cref="Hotkey"/> that was created, otherwise null.</returns>
        public virtual Hotkey Register(Keys key, ModKeys modifiers, string description)
        {
            if (_registers.Any(hkk => string.Equals(hkk.Description, description) || (hkk.Modifiers == modifiers && hkk.Key == key)))
            {
                return(null);
            }
            Hotkey hk = Hotkey.Create(key, modifiers, description);

            _registers.Add(hk);
            if (IsHooked == false)
            {
                try {
                    IsHooked = Hook();
                } catch (Exception e) {
                    throw new Exception("Failed to perform hook. see inner exception.", e);
                }
            }
            return(hk);
        }
Esempio n. 29
0
        /// <summary>
        /// Convierte de Keys a ModKeys para ser usado con la funcion RegisterHotKey
        /// </summary>
        public static ModKeys ToModKeys(Keys k)
        {
            ModKeys mods = 0x0;

            if (k.HasFlag(Keys.Control))
            {
                mods |= ModKeys.Control;
            }
            if (k.HasFlag(Keys.Shift))
            {
                mods |= ModKeys.Shift;
            }
            if (k.HasFlag(Keys.Alt))
            {
                mods |= ModKeys.Alt;
            }

            return(mods);
        }
Esempio n. 30
0
        /// <summary>
        /// Press down a key
        /// </summary>
        /// <param name="key">The key to be pressed down</param>
        /// <param name="mods">Modifiers</param>
        public static void KeyDown(Keys key, ModKeys mods = ModKeys.None)
        {
            mods = RemoveRedundantMods(key, mods);
            if ((mods & ModKeys.Alt) != 0)
            {
                keybd_event((byte)Keys.Menu, 0, 0, 0);
            }

            if ((mods & ModKeys.Control) != 0)
            {
                keybd_event((byte)Keys.ControlKey, 0, 0, 0);
            }

            if ((mods & ModKeys.Shift) != 0)
            {
                keybd_event((byte)Keys.ShiftKey, 0, 0, 0);
            }

            keybd_event((byte)key, 0, 0, 0);
        }
Esempio n. 31
0
        public bool RegisterOriginalHotkey(Keys hotkey, int hotkeyValue, ModKeys modifiers)
        {
            var modKey = Keys.None;

            if ((modifiers & ModKeys.Alt) == ModKeys.Alt)
            {
                modKey = modKey | Keys.Alt;
            }

            if ((modifiers & ModKeys.Ctrl) == ModKeys.Ctrl)
            {
                modKey = modKey | Keys.Control;
            }

            if ((modifiers & ModKeys.Shift) == ModKeys.Shift)
            {
                modKey = modKey | Keys.Shift;
            }

            if ((modifiers & ModKeys.Win) == ModKeys.Win)
            {
                modKey = modKey | Keys.LWin;
            }

            var key = new KeyEventArgs(hotkey | modKey);

            if (_hotkeyIds.Any(kvp => kvp.Value.KeyEvent.KeyData == key.KeyData && kvp.Value.Value == hotkeyValue))
            {
                return(true);
            }

            int hotkeyId = Win32Api.RegisterGlobalHotKey(hotkeyValue, (int)modifiers, _targetForm);

            if (hotkeyId > 0)
            {
                _hotkeyIds.Add(hotkeyId, new KeyEventValue(key, hotkeyValue));
                return(true);
            }

            return(false);
        }
Esempio n. 32
0
        /// <summary>
        /// Register a hotkey
        /// </summary>
        /// <param name="hWnd">Handle of the window which will receive WM_HOTKEY event</param>
        /// <param name="id">Unique identity of the hotkey</param>
        /// <param name="vk">Key</param>
        /// <param name="mods">Modifiers, default is none</param>
        /// <returns></returns>
        public static bool RegisterHotKey(IntPtr hWnd, int id, Keys vk, ModKeys mods = ModKeys.None)
        {
            int flags = 0;

            if ((mods & ModKeys.Alt) != 0)
            {
                flags |= MOD_ALT;
            }

            if ((mods & ModKeys.Shift) != 0)
            {
                flags |= MOD_SHIFT;
            }

            if ((mods & ModKeys.Control) != 0)
            {
                flags |= MOD_CONTROL;
            }

            return(RegisterHotKey(hWnd, id, flags, vk));
        }
Esempio n. 33
0
File: Hotkey.cs Progetto: Nucs/nlib
 public Hotkey(Keys key, ModKeys modifiers, string description) {
     Modifiers = modifiers;
     Key = key;
     Description = description;
 }
Esempio n. 34
0
 public bool RegisterOriginalHotkey(Keys hotkey, int hotkeyValue, ModKeys modifiers)
 {
     var modKey = Keys.None;
     if ((modifiers & ModKeys.Alt) == ModKeys.Alt) modKey |= Keys.Alt;
     if ((modifiers & ModKeys.Ctrl) == ModKeys.Ctrl) modKey |= Keys.Control;
     if ((modifiers & ModKeys.Shift) == ModKeys.Shift) modKey |= Keys.Shift;
     if ((modifiers & ModKeys.Win) == ModKeys.Win) modKey |= Keys.LWin;
     var key = new KeyEventArgs(hotkey | modKey);
     foreach (var kvp in this._hotkeyID)
     {
         if (kvp.Value.KeyEvent.KeyData == key.KeyData && kvp.Value.Value == hotkeyValue) return true; // 登録済みなら正常終了
     }
     var hotkeyId = NativeMethods.RegisterGlobalHotKey(hotkeyValue, (int)modifiers, this._targetForm);
     if (hotkeyId > 0)
     {
         this._hotkeyID.Add(hotkeyId, new KeyEventValue(key, hotkeyValue));
         return true;
     }
     return false;
 }
Esempio n. 35
0
File: ModKeys.cs Progetto: Nucs/nlib
 /// <summary>
 /// Compares two <see cref="ModKeys"/>. Use this instead of == or .Equals!!
 /// </summary>
 public static bool Compare(this ModKeys mk, ModKeys to) {
     var mk_side = mk.ExportSide();
     var to_side = to.ExportSide();
     if (mk_side != ModKeys.RLKey && to_side != ModKeys.RLKey && mk_side != to_side) return false;
     return ((int) mk & ~3) == ((int) to & ~3); //compare with elimination of sides.
 }
Esempio n. 36
0
        void SendKeystroke(byte bkey,ModKeys ModKey)
        {
            if(KeyInUse)
            {
                Sleep(RETRY_TIME);
                SendKeystroke(bkey,ModKey);
                return;
            }
            else
            {
                KeyInUse = true;
                if(ModKey == ModKeys.Shift) {
                    keybd_event((byte)VirtualKeys.Shift,0,0,0);
                    Sleep(CLICK_PAUSETIME);
                } else if(ModKey == ModKeys.Ctrl) {
                    keybd_event((byte)VirtualKeys.Control,0,0,0);
                    Sleep(CLICK_PAUSETIME);
                }
            //				else if(ModKeys = ModKeys.Alt) {
            //					keybd_event((byte)VirtualKeys.Alt,0,0,0);
            //					Sleep(CLICK_PAUSETIME);
            //				}

                // key down
                keybd_event(bkey,0,0,0);
                Sleep(CLICK_PAUSETIME);

                if(ModKey == ModKeys.Shift) {
                    keybd_event((byte)VirtualKeys.Shift,0,KEYEVENTF_KEYUP,0);
                    Sleep(CLICK_PAUSETIME);
                } else if(ModKey == ModKeys.Ctrl) {
                    keybd_event((byte)VirtualKeys.Control,0,KEYEVENTF_KEYUP,0);
                    Sleep(CLICK_PAUSETIME);
                }

                // key up
                keybd_event(bkey,0,KEYEVENTF_KEYUP,0);
                Sleep(CLICK_PAUSETIME);
                KeyInUse = false;
            }
        }
Esempio n. 37
0
        public bool RegisterOriginalHotkey(Keys hotkey, int hotkeyValue, ModKeys modifiers)
        {
            var modKey = Keys.None;
            if ((modifiers & ModKeys.Alt) == ModKeys.Alt)
            {
                modKey = modKey | Keys.Alt;
            }

            if ((modifiers & ModKeys.Ctrl) == ModKeys.Ctrl)
            {
                modKey = modKey | Keys.Control;
            }

            if ((modifiers & ModKeys.Shift) == ModKeys.Shift)
            {
                modKey = modKey | Keys.Shift;
            }

            if ((modifiers & ModKeys.Win) == ModKeys.Win)
            {
                modKey = modKey | Keys.LWin;
            }

            var key = new KeyEventArgs(hotkey | modKey);
            if (_hotkeyIds.Any(kvp => kvp.Value.KeyEvent.KeyData == key.KeyData && kvp.Value.Value == hotkeyValue))
            {
                return true;
            }

            int hotkeyId = Win32Api.RegisterGlobalHotKey(hotkeyValue, (int)modifiers, _targetForm);
            if (hotkeyId > 0)
            {
                _hotkeyIds.Add(hotkeyId, new KeyEventValue(key, hotkeyValue));
                return true;
            }

            return false;
        }
Esempio n. 38
0
 public EventArgs1(ModKeys modKeys_1, Keys keys_1)
 {
     this.modKeys_0 = modKeys_1;
     this.keys_0 = keys_1;
 }
Esempio n. 39
0
File: Hotkey.cs Progetto: Nucs/nlib
 internal static Hotkey Create(Keys key, ModKeys modifiers, string description) { return new Hotkey(key, modifiers, description); }
Esempio n. 40
0
 public static KeyData Get( int key, ModKeys mod )
 {
     for(int i=0;i<m_List.Count;i++)
     {
         KeyData hk = (KeyData)m_List[i];
         if ( hk.Key == key && hk.Mod == mod && hk.Key != 0 )
             return hk;
     }
     return null;
 }