babalae/better-genshin-impact · error · Exception
游戏窗口分辨率不是 16:9
Error message
游戏窗口分辨率不是 16:9
What it means
A generic Exception from AssertUtils.CheckGameResolution thrown when the game window's screen rect does not satisfy a 16:9 aspect ratio (width*9 != height*16). Genshin Impact automation relies on template matching and coordinate math tuned for 16:9, so non-conforming resolutions are rejected to avoid misbehavior. A LogError is emitted before the throw.
Source
Thrown at BetterGenshinImpact/Helpers/AssertUtils.cs:29
{
if (!b)
{
throw new System.Exception(msg);
}
}
/// <summary>
/// 强制要求游戏分辨率检查
/// 要求功能必须处于启用状态
/// </summary>
public static void CheckGameResolution(string msg = "")
{
var gameScreenSize = SystemControl.GetGameScreenRect(TaskContext.Instance().GameHandle);
if (gameScreenSize.Width * 9 != gameScreenSize.Height * 16)
{
TaskControl.Logger.LogError("游戏窗口分辨率不是 16:9 !当前分辨率为 {Width}x{Height} , 非 16:9 分辨率的游戏无法正常使用{Msg}功能 !", gameScreenSize.Width, gameScreenSize.Height, msg);
throw new Exception("游戏窗口分辨率不是 16:9");
}
}
}View on GitHub (pinned to a7cb36712d)
Solutions
- Set the game to a 16:9 resolution (e.g. 1920x1080, 1600x900, 1280x720) in windowed or borderless mode.
- Disable OS-level DPI scaling overrides for the game so the client rect is accurate.
- Ensure no letterboxing/black bars are present inside the window.
- Re-run the feature once the window reports a 16:9 client area.
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
var rect = SystemControl.GetGameScreenRect(TaskContext.Instance().GameHandle);
if (rect.Width * 9 != rect.Height * 16) { /* prompt user to set 16:9; do not proceed */ } Type guard
static bool IsSixteenNine(SystemControl.RECT r) => r.Width * 9 == r.Height * 16;
Try / catch
try { AssertUtils.CheckGameResolution("自动战斗"); }
catch (Exception ex) { Toast.Warning(ex.Message); return; } Prevention
- Run Genshin at a 16:9 resolution (1920x1080, 1600x900, 1280x720).
- Disable DPI scaling overrides for the game.
- Avoid letterboxed/ultrawide modes.
When it happens
Trigger: Calling CheckGameResolution (directly or via a feature that asserts it) when the game window has a non-16:9 client area, e.g. ultrawide 21:9, 4:3, a windowed custom size, or a resolution with black bars/scaled client area.
Common situations: Running the game in ultrawide or non-standard windowed mode; DPI scaling or letterboxing distorting the reported client rect; the game set to a resolution like 1600x900 vs 1366x768 that is 16:9 but the window chrome skews GetGameScreenRect.
Related errors
- 游戏窗口分辨率小于 1920x1080 !无法使用地图追踪功能!
- 游戏窗口分辨率不是 16:9
- 游戏窗口分辨率不得小于 800x600 !
- 未找到{taskName}的素材文件夹
- 不在主界面,无法识别小地图坐标
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/c5cf13a1ba40b70c.
Report an issue: GitHub.