mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[PastePlain]Support Ctrl+V as activation (#24448)
This commit is contained in:
@@ -125,6 +125,10 @@ public:
|
|||||||
return powertoys_gpo::gpo_rule_configured_not_configured;
|
return powertoys_gpo::gpo_rule_configured_not_configured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some actions like PastePlain generate new inputs, which we don't want to catch again.
|
||||||
|
// The flag was purposefully chose to not collide with other keyboard manager flags.
|
||||||
|
const static inline ULONG_PTR CENTRALIZED_KEYBOARD_HOOK_DONT_TRIGGER_FLAG = 0x110;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HANDLE CreateDefaultEvent(const wchar_t* eventName)
|
HANDLE CreateDefaultEvent(const wchar_t* eventName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -311,6 +311,8 @@ private:
|
|||||||
INPUT input_event = {};
|
INPUT input_event = {};
|
||||||
input_event.type = INPUT_KEYBOARD;
|
input_event.type = INPUT_KEYBOARD;
|
||||||
input_event.ki.wVk = 0x56; // V
|
input_event.ki.wVk = 0x56; // V
|
||||||
|
// Avoid triggering detection by the centralized keyboard hook. Allows using Control+V as activation.
|
||||||
|
input_event.ki.dwExtraInfo = CENTRALIZED_KEYBOARD_HOOK_DONT_TRIGGER_FLAG;
|
||||||
inputs.push_back(input_event);
|
inputs.push_back(input_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,6 +321,8 @@ private:
|
|||||||
input_event.type = INPUT_KEYBOARD;
|
input_event.type = INPUT_KEYBOARD;
|
||||||
input_event.ki.wVk = 0x56; // V
|
input_event.ki.wVk = 0x56; // V
|
||||||
input_event.ki.dwFlags = KEYEVENTF_KEYUP;
|
input_event.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||||
|
// Avoid triggering detection by the centralized keyboard hook. Allows using Control+V as activation.
|
||||||
|
input_event.ki.dwExtraInfo = CENTRALIZED_KEYBOARD_HOOK_DONT_TRIGGER_FLAG;
|
||||||
inputs.push_back(input_event);
|
inputs.push_back(input_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,12 @@ namespace CentralizedKeyboardHook
|
|||||||
|
|
||||||
const auto& keyPressInfo = *reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
|
const auto& keyPressInfo = *reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
|
||||||
|
|
||||||
|
if (keyPressInfo.dwExtraInfo == PowertoyModuleIface::CENTRALIZED_KEYBOARD_HOOK_DONT_TRIGGER_FLAG)
|
||||||
|
{
|
||||||
|
// The new keystroke was generated from one of our actions. We should pass it along.
|
||||||
|
return CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the keys are pressed.
|
// Check if the keys are pressed.
|
||||||
if (!pressedKeyDescriptors.empty())
|
if (!pressedKeyDescriptors.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user