babalae/better-genshin-impact · error · ArgumentException

游戏窗口分辨率不得小于 800x600 !

Error message

游戏窗口分辨率不得小于 800x600 !

What it means

Thrown by the SystemInfo constructor when SystemControl.GetGameScreenRect(hWnd) returns a RECT whose Width < 800 or Height < 600. The tool requires at least 800x600 game window resolution to perform reliable image recognition and asset scaling.

Source

Thrown at BetterGenshinImpact/GameTask/Model/SystemInfo.cs:80

            GameProcess = p ?? throw new ArgumentException("通过句柄获取游戏进程失败");
            GameProcessName = GameProcess.ProcessName;
            GameProcessId = GameProcess.Id;

            DisplaySize = PrimaryScreen.WorkingArea;
            DesktopRectArea = new DesktopRegion();

            // 判断最小化
            if (User32.IsIconic(hWnd))
            {
                throw new ArgumentException("游戏窗口不能最小化");
            }

            // 注意截图区域要和游戏窗口实际区域一致
            // todo 窗口移动后?
            GameScreenSize = SystemControl.GetGameScreenRect(hWnd);
            if (GameScreenSize.Width < 800 || GameScreenSize.Height < 600)
            {
                throw new ArgumentException("游戏窗口分辨率不得小于 800x600 !");
            }

            // 0.28 改动,素材缩放比例不可以超过 1,也就是图像识别时分辨率大于 1920x1080 的情况下直接进行缩放
            if (GameScreenSize.Width < 1920)
            {
                ZoomOutMax1080PRatio = GameScreenSize.Width / 1920d;
                AssetScale = ZoomOutMax1080PRatio;
            }
            ScaleTo1080PRatio = GameScreenSize.Width / 1920d; // 1080P 为标准

            CaptureAreaRect = SystemControl.GetCaptureRect(hWnd);
            if (CaptureAreaRect.Width > 1920)
            {
                var scale = CaptureAreaRect.Width / 1920d;
                ScaleMax1080PCaptureRect = new Rect(CaptureAreaRect.X, CaptureAreaRect.Y, 1920, (int)(CaptureAreaRect.Height / scale));
            }
            else
            {

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Ensure the game window is at least 800x600 (preferably 1920x1080 for best recognition accuracy).
  2. Add a small delay and retry GetGameScreenRect if the dimensions are suspiciously small, to handle window transition states.
  3. Catch ArgumentException at the call site and instruct the user to increase the window size.
  4. Verify DPI awareness settings so GetGameScreenRect returns physical rather than scaled pixels.
Defensive patterns

Strategy: validation

Validate before calling

var rect = SystemControl.GetGameScreenRect(hWnd);
if (rect.Width < 800 || rect.Height < 600)
{
    logger.LogError("游戏窗口分辨率过小:{W}x{H},请至少设置为 800x600", rect.Width, rect.Height);
    return;
}

Try / catch

try { var info = new SystemInfo(hWnd); }
catch (ArgumentException ex) when (ex.Message.Contains("分辨率"))
{ /* instruct user to increase resolution */ }

Prevention

When it happens

Trigger: Constructing SystemInfo when the game window is too small (below 800x600). This can occur if the user set a very small windowed mode, or if GetGameScreenRect returned an incorrect (e.g. zero-size) rect due to the window being in a transition state.

Common situations: Game running in a tiny windowed mode; the window is mid-resize or in a borderless transition when the rect was queried; DPI scaling causing incorrect client-area measurement.

Related errors


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