Esempio n. 1
0
 /// <summary>
 /// Controls when the key up event is fired up and treats it.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnKeyUp(object sender, WindowsHook.KeyEventArgs e)
 {
     // If it's '&' key and it hasn't been pressed before, the user might be starting to write the name of a macro.
     if (e.Shift && e.KeyCode == WindowsHook.Keys.D6 && !pressedAndpersand)
     {
         pressedAndpersand = true;
     }
     // If it's '#' and '&' has been pressed before, the used has written the name of a macro.
     else if (e.Alt && e.KeyCode == WindowsHook.Keys.D3 && pressedAndpersand && !string.IsNullOrWhiteSpace(macroName))
     {
         SetMacro();
     }
     // If the key number is between '0' and 'Z', it belongs to the tag name.
     else if (e.KeyData >= WindowsHook.Keys.D0 && e.KeyData <= WindowsHook.Keys.Z && pressedAndpersand)
     {
         macroName += (char)e.KeyData;
     }
 }
Esempio n. 2
0
        private void Hook_KeyDown(object sender, WindowsHook.KeyEventArgs e)
        {
            if (KEYS_INVALID.Contains(e.KeyCode))
            {
                return;
            }

            // Transfer the event key to a string to compare to settings
            var str = new StringBuilder();

            if (e.Modifiers.HasFlag(WindowsHook.Keys.Control))
            {
                str.Append("Ctrl+");
            }
            if (e.Modifiers.HasFlag(WindowsHook.Keys.Shift))
            {
                str.Append("Shift+");
            }
            if (e.Modifiers.HasFlag(WindowsHook.Keys.Alt))
            {
                str.Append("Alt+");
            }
            if (e.Modifiers.HasFlag(WindowsHook.Keys.LWin) || e.Modifiers.HasFlag(WindowsHook.Keys.RWin))
            {
                str.Append("Win+");
            }

            str.Append(e.KeyCode);

            if (OnKeyDown != null)
            {
                var result = OnKeyDown.Invoke(str.ToString());
                if (result)
                {
                    e.Handled = true;
                }
            }
        }
Esempio n. 3
0
        private void Hook_KeyDown(object sender, WindowsHook.KeyEventArgs e)
        {
            if ((!nativeProcess.IsPathOfExileInFocus && !nativeProcess.IsSidekickInFocus) || KEYS_INVALID.Contains(e.KeyCode))
            {
                return;
            }

            // Transfer the event key to a string to compare to settings
            var str = new StringBuilder();

            if (e.Modifiers.HasFlag(WindowsHook.Keys.Control))
            {
                str.Append("Ctrl+");
            }
            if (e.Modifiers.HasFlag(WindowsHook.Keys.Shift))
            {
                str.Append("Shift+");
            }
            if (e.Modifiers.HasFlag(WindowsHook.Keys.Alt))
            {
                str.Append("Alt+");
            }
            if (e.Modifiers.HasFlag(WindowsHook.Keys.LWin) || e.Modifiers.HasFlag(WindowsHook.Keys.RWin))
            {
                str.Append("Win+");
            }

            str.Append(e.KeyCode);

            str = str
                  .Replace("Back", "Backspace")
                  .Replace("Capital", "CapsLock")
                  .Replace("Next", "PageDown")
                  .Replace("Pause", "Break");

            e.Handled = OnKeyDown?.Invoke(str.ToString()) ?? false;
        }
Esempio n. 4
0
 private void OnKeyUp(object sender, KeyEventArgs e)
 {
     Log(string.Format("KeyUp  \t\t {0}\n", e.KeyCode));
 }