Files
PowerToys/src/modules/launcher/Wox/Helper/KeyboardHelper.cs
Tomas Agustin Raies 670033c4da [Settings/Run] LowLevel Keyboard hooking for Hotkeys (#3825)
* [Launcher/Settings] Low Level Keyboard Hooks

* [Run] LowLevel Keyboard Hook for Hotkeys

* Prevent shortcuts from auto repeating when keeping the keys pressed down
2020-06-11 12:59:36 -07:00

38 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using Wox.Plugin;
namespace Wox.Helper
{
class KeyboardHelper
{
public static SpecialKeyState CheckModifiers()
{
SpecialKeyState state = new SpecialKeyState();
if ((Keyboard.GetKeyStates(Key.LeftShift) & KeyStates.Down) > 0 ||
(Keyboard.GetKeyStates(Key.RightShift) & KeyStates.Down) > 0)
{
state.ShiftPressed = true;
}
if ((Keyboard.GetKeyStates(Key.LWin) & KeyStates.Down) > 0 ||
(Keyboard.GetKeyStates(Key.RWin) & KeyStates.Down) > 0)
{
state.WinPressed = true;
}
if ((Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) > 0 ||
(Keyboard.GetKeyStates(Key.RightCtrl) & KeyStates.Down) > 0)
{
state.CtrlPressed = true;
}
if ((Keyboard.GetKeyStates(Key.LeftAlt) & KeyStates.Down) > 0 ||
(Keyboard.GetKeyStates(Key.RightAlt) & KeyStates.Down) > 0)
{
state.AltPressed = true;
}
return state;
}
}
}