mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Runner: improve debugging experience with hooks
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "SecondaryMouseButtonsHook.h"
|
||||
#include <common/debug_control.h>
|
||||
|
||||
#pragma region public
|
||||
|
||||
@@ -9,11 +10,23 @@ std::function<void()> SecondaryMouseButtonsHook::callback = {};
|
||||
SecondaryMouseButtonsHook::SecondaryMouseButtonsHook(std::function<void()> extCallback)
|
||||
{
|
||||
callback = std::move(extCallback);
|
||||
#if defined(DISABLE_LOWLEVEL_KBHOOK_WHEN_DEBUGGED)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
hHook = SetWindowsHookEx(WH_MOUSE_LL, SecondaryMouseButtonsProc, GetModuleHandle(NULL), 0);
|
||||
}
|
||||
|
||||
void SecondaryMouseButtonsHook::enable()
|
||||
{
|
||||
#if defined(DISABLE_LOWLEVEL_KBHOOK_WHEN_DEBUGGED)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!hHook)
|
||||
{
|
||||
hHook = SetWindowsHookEx(WH_MOUSE_LL, SecondaryMouseButtonsProc, GetModuleHandle(NULL), 0);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "ShiftKeyHook.h"
|
||||
|
||||
#include <common/debug_control.h>
|
||||
|
||||
#pragma region public
|
||||
|
||||
HHOOK ShiftKeyHook::hHook = {};
|
||||
@@ -9,11 +11,23 @@ std::function<void(bool)> ShiftKeyHook::callback = {};
|
||||
ShiftKeyHook::ShiftKeyHook(std::function<void(bool)> extCallback)
|
||||
{
|
||||
callback = std::move(extCallback);
|
||||
#if defined(DISABLE_LOWLEVEL_KBHOOK_WHEN_DEBUGGED)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, ShiftKeyHookProc, GetModuleHandle(NULL), 0);
|
||||
}
|
||||
|
||||
void ShiftKeyHook::enable()
|
||||
{
|
||||
#if defined(DISABLE_LOWLEVEL_KBHOOK_WHEN_DEBUGGED)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!hHook)
|
||||
{
|
||||
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, ShiftKeyHookProc, GetModuleHandle(NULL), 0);
|
||||
|
||||
Reference in New Issue
Block a user