doc/devdocs/modules/mouseutils/findmymouse.md
Find My Mouse is a utility that helps users locate their mouse pointer by creating a spotlight effect when activated. It is based on Raymond Chen's SuperSonar utility.
Find My Mouse displays a spotlight effect centered on the cursor location when activated via a keyboard shortcut (typically a double-press of the Ctrl key).
src/modules/MouseUtils/FindMyMouse/FindMyMouse.cpp - Contains the main implementations_WndProc - Handles window messages for the utilityWhen the utility is enabled:
A background thread is created to run the Find My Mouse logic asynchronously:
// Enable the PowerToy
virtual void enable()
{
m_enabled = true; // Mark the module as enabled
Trace::EnableFindMyMouse(true); // Enable telemetry
std::thread([=]() { FindMyMouseMain(m_hModule, m_findMyMouseSettings); }).detach(); // Run main logic in background
}
The CompositionSpotlight instance is initialized with user settings:
CompositionSpotlight sonar;
sonar.ApplySettings(settings, false); // Apply settings
if (!sonar.Initialize(hinst))
{
Logger::error("Couldn't initialize a sonar instance.");
return 0;
}
m_sonar = &sonar;
The utility listens for raw input events using WM_INPUT, which provides more precise and responsive input detection than standard mouse events.
The activation process works as follows:
Keyboard Hook Detects Shortcut
WM_PRIV_SHORTCUT message to the sonar window:
virtual void OnHotkeyEx() override
{
Logger::trace("OnHotkeyEx()");
HWND hwnd = GetSonarHwnd();
if (hwnd != nullptr)
{
PostMessageW(hwnd, WM_PRIV_SHORTCUT, NULL, NULL);
}
}
Message Handler Triggers Action
BaseWndProc()if (message == WM_PRIV_SHORTCUT)
{
if (m_sonarStart == NoSonar)
StartSonar(); // Trigger sonar animation
else
StopSonar(); // Cancel if already running
}
Sonar Animation
StartSonar() uses CompositionSpotlight to display a highlight (ripple/pulse) centered on the mouse pointerThe Find My Mouse utility handles several types of events:
When the main window receives a WM_DESTROY message (on shutdown or disable), the sonar instance is properly cleaned up, and the message loop ends gracefully.
To debug Find My Mouse:
FindMyMouse.cpp file