babalae/better-genshin-impact · error · Exception

游戏窗口分辨率小于 1920x1080 !无法使用地图追踪功能!

Error message

游戏窗口分辨率小于 1920x1080 !无法使用地图追踪功能!

What it means

Thrown by PathExecutor when the Genshin Impact client window's client rect (via User32.GetClientRect on the game HWND) reports a width below 1920 or height below 1080. The 16:9 aspect-ratio check runs first (PathExecutor.cs:389), so this only fires for windows that are already 16:9 but too small. The path-tracking CV pipeline is calibrated against 1920x1080 templates, so sub-1080 captures produce unusable matches.

Source

Thrown at BetterGenshinImpact/GameTask/AutoPathing/PathExecutor.cs:400

        WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<object>(this,
            "UpdateCurrentPathing", new object(), task));
    }

    private void LogScreenResolution()
    {
        var gameScreenSize = SystemControl.GetGameScreenRect(TaskContext.Instance().GameHandle);
        if (gameScreenSize.Width * 9 != gameScreenSize.Height * 16)
        {
            Logger.LogError("游戏窗口分辨率不是 16:9 !当前分辨率为 {Width}x{Height} , 非 16:9 分辨率的游戏无法正常使用地图追踪功能!",
                gameScreenSize.Width, gameScreenSize.Height);
            throw new Exception("游戏窗口分辨率不是 16:9 !无法使用地图追踪功能!");
        }

        if (gameScreenSize.Width < 1920 || gameScreenSize.Height < 1080)
        {
            Logger.LogError("游戏窗口分辨率小于 1920x1080 !当前分辨率为 {Width}x{Height} , 小于 1920x1080 的分辨率的游戏地图追踪的效果非常差!",
                gameScreenSize.Width, gameScreenSize.Height);
            throw new Exception("游戏窗口分辨率小于 1920x1080 !无法使用地图追踪功能!");
        }
    }

    /// <summary>
    /// 切换队伍
    /// </summary>
    /// <param name="partyName"></param>
    /// <returns></returns>
    private async Task<bool> SwitchParty(string? partyName)
    {
        bool success = true;
        if (!string.IsNullOrEmpty(partyName))
        {
            if (RunnerContext.Instance.PartyName == partyName)
            {
                return success;
            }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Set the Genshin Impact in-game graphics resolution to 1920x1080 (or higher) and re-run the task.
  2. Switch the game display mode to fullscreen or borderless fullscreen at 1920x1080 so GetClientRect returns the full render area.
  3. Log off Windows / set display scaling to 100% if DPI virtualization is shrinking the client rect.
  4. Verify TaskContext.Instance().GameHandle points at the actual Genshin window (not a launcher/secondary process) before the check runs.

Example fix

// before: hard fail
if (gameScreenSize.Width < 1920 || gameScreenSize.Height < 1080)
    throw new Exception("游戏窗口分辨率小于 1920x1080 !无法使用地图追踪功能!");

// after: degrade gracefully with a warning instead of aborting
if (gameScreenSize.Width < 1920 || gameScreenSize.Height < 1080)
{
    Logger.LogWarning("游戏窗口分辨率 {W}x{H} 低于 1920x1080,地图追踪精度可能下降", gameScreenSize.Width, gameScreenSize.Height);
    return; // or continue with reduced accuracy mode
}
Defensive patterns

Strategy: validation

Validate before calling

var r = SystemControl.GetGameScreenRect(TaskContext.Instance().GameHandle);
if (r.Width < 1920 || r.Height < 1080 || r.Width * 9 != r.Height * 16)
    return Result.Fail($"游戏分辨率 {r.Width}x{r.Height} 不满足 1920x1080 16:9,请调整后重试");

Try / catch

try { ExecutePathing(); }
catch (Exception e) when (e.Message.Contains("1920x1080"))
{ /* prompt user to raise resolution, do not retry */ }

Prevention

When it happens

Trigger: Running a map pathing/auto-pathing task while the game renders at 1600x900, 1280x720, borderless-windowed scaled by DPI, or any sub-1080 laptop panel. TaskContext.Instance().GameHandle must already resolve to the live Genshin window. Windowed mode where GetClientRect differs from the configured render resolution.

Common situations: Laptop with a 1366x768 or 1600x900 panel; DPI scaling >100% shrinking the client area; game set to windowed 720p; HDR/secondary monitor with lower resolution; user changed in-game resolution but did not restart the task.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/5962b770f9ce9ab6. Report an issue: GitHub.