File tree Expand file tree Collapse file tree
source/MaaWin32ControlUnit/Screencap Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
459484MAA_CTRL_UNIT_NS_END
460485
461486#endif
Original file line number Diff line number Diff 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
4546private:
4647 HWND hwnd_ = nullptr ;
You can’t perform that action at this time.
0 commit comments