diff --git a/BetterGenshinImpact/Core/Config/AllConfig.cs b/BetterGenshinImpact/Core/Config/AllConfig.cs
index a6445c00..b0907b9e 100644
--- a/BetterGenshinImpact/Core/Config/AllConfig.cs
+++ b/BetterGenshinImpact/Core/Config/AllConfig.cs
@@ -55,6 +55,12 @@ public partial class AllConfig : ObservableObject
[ObservableProperty]
private bool _wgcUseBitmapCache = true;
+ ///
+ /// 自动修复Win11下BitBlt截图方式不可用的问题
+ ///
+ [ObservableProperty]
+ private bool _autoFixWin11BitBlt = true;
+
///
/// 推理使用的设备
///
diff --git a/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs b/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs
index eec2e94c..3abb6413 100644
--- a/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs
+++ b/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs
@@ -143,7 +143,8 @@ namespace BetterGenshinImpact.GameTask
GameCapture.Start(hWnd,
new Dictionary()
{
- { "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache }
+ { "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache },
+ { "autoFixWin11BitBlt", OsVersionHelper.IsWindows11_OrGreater && TaskContext.Instance().Config.AutoFixWin11BitBlt }
}
);
diff --git a/BetterGenshinImpact/View/CaptureTestWindow.xaml.cs b/BetterGenshinImpact/View/CaptureTestWindow.xaml.cs
index bdb93743..366563b5 100644
--- a/BetterGenshinImpact/View/CaptureTestWindow.xaml.cs
+++ b/BetterGenshinImpact/View/CaptureTestWindow.xaml.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
+using BetterGenshinImpact.Helpers;
using Wpf.Ui.Violeta.Controls;
namespace BetterGenshinImpact.View;
@@ -48,7 +49,8 @@ public partial class CaptureTestWindow : Window
_capture.Start(hWnd,
new Dictionary()
{
- { "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache }
+ { "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache },
+ { "autoFixWin11BitBlt", OsVersionHelper.IsWindows11 && TaskContext.Instance().Config.AutoFixWin11BitBlt }
}
);
diff --git a/BetterGenshinImpact/View/Pages/HomePage.xaml b/BetterGenshinImpact/View/Pages/HomePage.xaml
index 9b8d991f..10edb1c8 100644
--- a/BetterGenshinImpact/View/Pages/HomePage.xaml
+++ b/BetterGenshinImpact/View/Pages/HomePage.xaml
@@ -296,23 +296,29 @@
+
+
+ Content="手动设置" />
diff --git a/BetterGenshinImpact/View/Pages/View/PathingConfigView.xaml b/BetterGenshinImpact/View/Pages/View/PathingConfigView.xaml
index 283b6003..99b9c17f 100644
--- a/BetterGenshinImpact/View/Pages/View/PathingConfigView.xaml
+++ b/BetterGenshinImpact/View/Pages/View/PathingConfigView.xaml
@@ -13,8 +13,15 @@
d:DesignHeight="450"
d:DesignWidth="300"
mc:Ignorable="d">
+
+
-
+
+
+
+
+
+
@@ -47,14 +54,24 @@
+ SelectionMode="Multiple">
+
+
则使用
diff --git a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs
index f2adf051..2bf72ed8 100644
--- a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs
+++ b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs
@@ -1,11 +1,13 @@
using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Core.Recognition.OCR;
using BetterGenshinImpact.Core.Script;
+using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.Helpers;
using BetterGenshinImpact.Model;
using BetterGenshinImpact.Service.Interface;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using Fischless.GameCapture.BitBlt;
using Microsoft.Extensions.Logging;
using OpenCvSharp;
using System;
@@ -108,6 +110,13 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
_logger.LogWarning("获取 BetterGI 最新版本信息失败");
}
+ // Win11下 BitBlt截图方式不可用,需要关闭窗口优化功能
+ if (OsVersionHelper.IsWindows11_OrGreater && TaskContext.Instance().Config.AutoFixWin11BitBlt)
+ {
+ BitBltRegistryHelper.SetDirectXUserGlobalSettings();
+ }
+
+ // 更新仓库
ScriptRepoUpdater.Instance.AutoUpdate();
}
diff --git a/Fischless.GameCapture/BitBlt/BitBltCapture.cs b/Fischless.GameCapture/BitBlt/BitBltCapture.cs
index e529c92e..de379344 100644
--- a/Fischless.GameCapture/BitBlt/BitBltCapture.cs
+++ b/Fischless.GameCapture/BitBlt/BitBltCapture.cs
@@ -17,6 +17,13 @@ public class BitBltCapture : IGameCapture
{
_hWnd = hWnd;
IsCapturing = true;
+ if (settings != null && settings.TryGetValue("autoFixWin11BitBlt", out var value))
+ {
+ if (value is true)
+ {
+ BitBltRegistryHelper.SetDirectXUserGlobalSettings();
+ }
+ }
}
public Bitmap? Capture()
diff --git a/Fischless.GameCapture/BitBlt/BitBltRegistryHelper.cs b/Fischless.GameCapture/BitBlt/BitBltRegistryHelper.cs
new file mode 100644
index 00000000..c23cce94
--- /dev/null
+++ b/Fischless.GameCapture/BitBlt/BitBltRegistryHelper.cs
@@ -0,0 +1,32 @@
+using System.Diagnostics;
+using Microsoft.Win32;
+
+namespace Fischless.GameCapture.BitBlt;
+
+public class BitBltRegistryHelper
+{
+ ///
+ /// https://github.com/babalae/better-genshin-impact/issues/92
+ /// Win11下 BitBlt截图方式不可用,需要关闭窗口优化功能,这是具体的注册表操作
+ /// \HKEY_CURRENT_USER\Software\Microsoft\DirectX\UserGpuPreferences
+ /// DirectXUserGlobalSettings = SwapEffectUpgradeEnable=0;
+ ///
+ /// 要在游戏启动前设置才有效
+ ///
+ public static void SetDirectXUserGlobalSettings()
+ {
+ try
+ {
+ const string keyPath = @"Software\Microsoft\DirectX\UserGpuPreferences";
+ const string valueName = "DirectXUserGlobalSettings";
+ const string valueData = "SwapEffectUpgradeEnable=0;";
+
+ using var key = Registry.CurrentUser.CreateSubKey(keyPath);
+ key.SetValue(valueName, valueData, RegistryValueKind.String);
+ }
+ catch (Exception e)
+ {
+ Debug.WriteLine(e);
+ }
+ }
+}