mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-19 22:37:58 +08:00
c93eb92cd0
* rename dll -> FancyZonesModuleInterface (#11488) * [FancyZones] Rename "fancyzones/tests" -> "fancyzones/FancyZonesTests" (#11492) * [FancyZones] Rename "fancyzones/lib" -> "fancyzones/FancyZonesLib" (#11489) * [FancyZones] New FancyZones project. (#11544) * [FancyZones] Allow single instance of "PowerToys.FancyZones.exe" (#11558) * [FancyZones] Updated bug reports (#11571) * [FancyZones] Updated installer (#11572) * [FancyZones] Update string resources (#11596) * [FancyZones] Terminate FancyZones with runner (#11696) * [FancyZones] Drop support for the module interface API to save settings (#11661) * Settings telemetry for FancyZones (#11766) * commented out test * enable dpi awareness for the process
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#include "pch.h"
|
|
#include "SecondaryMouseButtonsHook.h"
|
|
#include <common/debug_control.h>
|
|
|
|
#pragma region public
|
|
|
|
HHOOK SecondaryMouseButtonsHook::hHook = {};
|
|
std::function<void()> SecondaryMouseButtonsHook::callback = {};
|
|
|
|
SecondaryMouseButtonsHook::SecondaryMouseButtonsHook(std::function<void()> extCallback)
|
|
{
|
|
callback = std::move(extCallback);
|
|
}
|
|
|
|
void SecondaryMouseButtonsHook::enable()
|
|
{
|
|
#if defined(DISABLE_LOWLEVEL_HOOKS_WHEN_DEBUGGED)
|
|
if (IsDebuggerPresent())
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
if (!hHook)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_MOUSE_LL, SecondaryMouseButtonsProc, GetModuleHandle(NULL), 0);
|
|
}
|
|
}
|
|
|
|
void SecondaryMouseButtonsHook::disable()
|
|
{
|
|
if (hHook)
|
|
{
|
|
UnhookWindowsHookEx(hHook);
|
|
hHook = NULL;
|
|
}
|
|
}
|
|
|
|
#pragma endregion
|
|
|
|
#pragma region private
|
|
|
|
LRESULT CALLBACK SecondaryMouseButtonsHook::SecondaryMouseButtonsProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
if (nCode == HC_ACTION)
|
|
{
|
|
if (wParam == WM_RBUTTONDOWN || wParam == WM_MBUTTONDOWN || wParam == WM_XBUTTONDOWN)
|
|
{
|
|
callback();
|
|
}
|
|
}
|
|
return CallNextHookEx(hHook, nCode, wParam, lParam);
|
|
}
|
|
|
|
#pragma endregion
|