{"record":{"id":"91ec0637b876ac8e","repo":"babalae/better-genshin-impact","slug":"error-91ec06","errorCode":null,"errorMessage":"游戏窗口不能最小化","messagePattern":"游戏窗口不能最小化","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Model/SystemInfo.cs","lineNumber":72,"sourceCode":"\n        public int GameProcessId { get; }\n\n        public DesktopRegion DesktopRectArea { get; }\n\n        public SystemInfo(IntPtr hWnd)\n        {\n            var p = SystemControl.GetProcessByHandle(hWnd);\n            GameProcess = p ?? throw new ArgumentException(\"通过句柄获取游戏进程失败\");\n            GameProcessName = GameProcess.ProcessName;\n            GameProcessId = GameProcess.Id;\n\n            DisplaySize = PrimaryScreen.WorkingArea;\n            DesktopRectArea = new DesktopRegion();\n\n            // 判断最小化\n            if (User32.IsIconic(hWnd))\n            {\n                throw new ArgumentException(\"游戏窗口不能最小化\");\n            }\n\n            // 注意截图区域要和游戏窗口实际区域一致\n            // todo 窗口移动后？\n            GameScreenSize = SystemControl.GetGameScreenRect(hWnd);\n            if (GameScreenSize.Width < 800 || GameScreenSize.Height < 600)\n            {\n                throw new ArgumentException(\"游戏窗口分辨率不得小于 800x600 ！\");\n            }\n\n            // 0.28 改动，素材缩放比例不可以超过 1，也就是图像识别时分辨率大于 1920x1080 的情况下直接进行缩放\n            if (GameScreenSize.Width < 1920)\n            {\n                ZoomOutMax1080PRatio = GameScreenSize.Width / 1920d;\n                AssetScale = ZoomOutMax1080PRatio;\n            }\n            ScaleTo1080PRatio = GameScreenSize.Width / 1920d; // 1080P 为标准\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Model/SystemInfo.cs#L54-L90","documentation":"Thrown by the SystemInfo constructor when User32.IsIconic(hWnd) returns true, indicating the game window is currently minimized. A minimized window cannot be captured for screen analysis, so the constructor rejects it with an ArgumentException.","triggerScenarios":"Constructing SystemInfo while the Genshin Impact game window is minimized to the taskbar. The tool requires a visible, properly-sized window to capture screenshots and compute regions.","commonSituations":"The user minimized the game manually; the game auto-minimized due to focus loss; another tool or overlay caused the window to minimize.","solutions":["Restore the game window from minimized state before starting any task.","At the call site, detect minimized state and prompt the user to restore the window before constructing SystemInfo.","Optionally call User32.ShowWindowAsync(hWnd, SW_RESTORE) to programmatically restore the window before proceeding.","Catch ArgumentException and show a user-friendly dialog (ThemedMessageBox) asking to un-minimize the game."],"exampleFix":"// before\nif (User32.IsIconic(hWnd))\n{\n    throw new ArgumentException(\"游戏窗口不能最小化\");\n}\n\n// after — attempt to restore before failing\nif (User32.IsIconic(hWnd))\n{\n    User32.ShowWindowAsync(hWnd, User32.ShowWindowCommand.SW_RESTORE);\n    Thread.Sleep(500);\n    if (User32.IsIconic(hWnd))\n        throw new ArgumentException(\"游戏窗口不能最小化，请手动恢复窗口后重试\");\n}","handlingStrategy":"validation","validationCode":"if (User32.IsIconic(hWnd))\n{\n    // Prompt user or attempt restore\n    logger.LogWarning(\"游戏窗口已最小化，请恢复窗口后重试\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { var info = new SystemInfo(hWnd); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"最小化\"))\n{ /* prompt user to restore the window */ }","preventionTips":["Check window state before starting tasks.","Prompt the user with ThemedMessageBox to restore the game window.","Optionally auto-restore the window via ShowWindowAsync before constructing SystemInfo."],"tags":["win32","system-info","game-window","user-action"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}