Skip to content

Commit ea8c60c

Browse files
committed
feat: win32 secondary_windows
1 parent 2b85522 commit ea8c60c

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
@@ -305,6 +305,9 @@ bool FramePoolScreencap::init()
305305
// 尝试关闭截图时的鼠标指针(Windows 10 2004 及以上支持)
306306
try_disable_cursor();
307307

308+
// 尝试包含从属窗口(弹窗、工具提示等)
309+
try_include_secondary_windows();
310+
308311
try {
309312
cap_session_.StartCapture();
310313
}
@@ -481,6 +484,28 @@ void FramePoolScreencap::try_disable_cursor()
481484
}
482485
}
483486

487+
void FramePoolScreencap::try_include_secondary_windows()
488+
{
489+
LogFunc;
490+
491+
using namespace winrt::Windows::Foundation::Metadata;
492+
493+
if (!ApiInformation::IsPropertyPresent(
494+
L"Windows.Graphics.Capture.GraphicsCaptureSession",
495+
L"IncludeSecondaryWindows")) {
496+
LogInfo << "IncludeSecondaryWindows property not supported on this system";
497+
return;
498+
}
499+
500+
try {
501+
cap_session_.IncludeSecondaryWindows(true);
502+
LogInfo << "Secondary windows capture enabled successfully";
503+
}
504+
catch (const winrt::hresult_error& e) {
505+
LogWarn << "Failed to enable secondary windows capture" << VAR(e.code()) << VAR(winrt::to_string(e.message()));
506+
}
507+
}
508+
484509
MAA_CTRL_UNIT_NS_END
485510

486511
#endif

source/MaaWin32ControlUnit/Screencap/FramePoolScreencap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class FramePoolScreencap : public ScreencapBase
4242
bool check_and_handle_size_changed();
4343
void try_disable_border();
4444
void try_disable_cursor();
45+
void try_include_secondary_windows();
4546

4647
private:
4748
HWND hwnd_ = nullptr;

0 commit comments

Comments
 (0)