mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
feat: GraphicsCapture 在Win11中不显示黄色边框
This commit is contained in:
parent
89ae4695e5
commit
be01010eec
1 changed files with 19 additions and 0 deletions
|
|
@ -102,6 +102,7 @@ bool GraphicsCaptureFrameSource::Initialize() {
|
|||
// 开始捕获
|
||||
_captureSession = _captureFramePool.CreateCaptureSession(_captureItem);
|
||||
|
||||
// 隐藏光标
|
||||
if (winrt::ApiInformation::IsPropertyPresent(
|
||||
L"Windows.Graphics.Capture.GraphicsCaptureSession",
|
||||
L"IsCursorCaptureEnabled"
|
||||
|
|
@ -112,6 +113,24 @@ bool GraphicsCaptureFrameSource::Initialize() {
|
|||
SPDLOG_LOGGER_INFO(logger, "当前系统无 IsCursorCaptureEnabled API");
|
||||
}
|
||||
|
||||
// 不显示黄色边框
|
||||
if (winrt::ApiInformation::IsPropertyPresent(
|
||||
L"Windows.Graphics.Capture.GraphicsCaptureSession",
|
||||
L"IsBorderRequired"
|
||||
)) {
|
||||
// 从 win11 开始提供
|
||||
// 先请求权限
|
||||
auto status = winrt::GraphicsCaptureAccess::RequestAccessAsync(winrt::GraphicsCaptureAccessKind::Borderless).get();
|
||||
if (status == decltype(status)::Allowed) {
|
||||
_captureSession.IsBorderRequired(false);
|
||||
} else {
|
||||
SPDLOG_LOGGER_INFO(logger, "IsCursorCaptureEnabled 失败");
|
||||
}
|
||||
|
||||
} else {
|
||||
SPDLOG_LOGGER_INFO(logger, "当前系统无 IsBorderRequired API");
|
||||
}
|
||||
|
||||
_captureSession.StartCapture();
|
||||
} catch (const winrt::hresult_error& e) {
|
||||
SPDLOG_LOGGER_ERROR(logger, fmt::format("初始化 WinRT 失败:{}", StrUtils::UTF16ToUTF8(e.message())));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue