Skip to content

Commit 2b85522

Browse files
committed
feat: win32 WGC try_disable_cursor
1 parent 965647b commit 2b85522

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

source/MaaWin32ControlUnit/Screencap/FramePoolScreencap.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ bool FramePoolScreencap::init()
302302
// 尝试关闭截图时的黄色边框(Windows 11 及部分 Win10 版本支持)
303303
try_disable_border();
304304

305+
// 尝试关闭截图时的鼠标指针(Windows 10 2004 及以上支持)
306+
try_disable_cursor();
307+
305308
try {
306309
cap_session_.StartCapture();
307310
}
@@ -456,6 +459,28 @@ void FramePoolScreencap::try_disable_border()
456459
}
457460
}
458461

462+
void FramePoolScreencap::try_disable_cursor()
463+
{
464+
LogFunc;
465+
466+
using namespace winrt::Windows::Foundation::Metadata;
467+
468+
if (!ApiInformation::IsPropertyPresent(
469+
L"Windows.Graphics.Capture.GraphicsCaptureSession",
470+
L"IsCursorCaptureEnabled")) {
471+
LogInfo << "IsCursorCaptureEnabled property not supported on this system";
472+
return;
473+
}
474+
475+
try {
476+
cap_session_.IsCursorCaptureEnabled(false);
477+
LogInfo << "Cursor capture disabled successfully";
478+
}
479+
catch (const winrt::hresult_error& e) {
480+
LogWarn << "Failed to disable cursor capture" << VAR(e.code()) << VAR(winrt::to_string(e.message()));
481+
}
482+
}
483+
459484
MAA_CTRL_UNIT_NS_END
460485

461486
#endif

source/MaaWin32ControlUnit/Screencap/FramePoolScreencap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class FramePoolScreencap : public ScreencapBase
4141
void uninit();
4242
bool check_and_handle_size_changed();
4343
void try_disable_border();
44+
void try_disable_cursor();
4445

4546
private:
4647
HWND hwnd_ = nullptr;

0 commit comments

Comments
 (0)