{"record":{"id":"e1dc4d779db14495","repo":"babalae/better-genshin-impact","slug":"paramname-0","errorCode":null,"errorMessage":"{paramName} 必须大于 0","messagePattern":"(.+?) 必须大于 0","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/BgiVision/BvFlow.cs","lineNumber":310,"sourceCode":"    }\n\n    internal BvLocator CreateAnyTextLocator(object texts, Rect rect)\n    {\n        return _page.GetByAnyText(texts, rect);\n    }\n\n    internal static IReadOnlyList<BvLocator> ParseTargets(object targets, string paramName)\n    {\n        return BvPage.ParseCollection<BvLocator>(targets, paramName)\n            .Select(target => target.Clone())\n            .ToArray();\n    }\n\n    internal static int ValidatePositive(int value, string paramName)\n    {\n        if (value <= 0)\n        {\n            throw new ArgumentOutOfRangeException(paramName, $\"{paramName} 必须大于 0\");\n        }\n\n        return value;\n    }\n\n    private BvFlowAction CreateImplicitPointAction(string description, Action<double, double> action)\n    {\n        return CreateAction(description, context =>\n        {\n            var (x, y) = context.GetLastMatchCenter();\n            action(x, y);\n            return Task.CompletedTask;\n        });\n    }\n\n    private BvFlowAction CreatePointAction(string description, double x, double y, Action<double, double> action)\n    {\n        return CreateAction(description, _ =>","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/BgiVision/BvFlow.cs#L292-L328","documentation":"Thrown by SendShortcut when the RDP connection state is not 1 (Connected). The Connected property of the ActiveX control must read exactly 1 to indicate a fully established, interactive session. Any other value (0=not connected, 2/3=connecting/disconnecting) means keystrokes cannot be delivered to the remote desktop.","triggerScenarios":"SendShortcut is called for Win+Tab or other shortcuts while ConnectedState != 1. Happens when the caller invokes shortcut-sending before OnConnected/OnLoginComplete fires, after a disconnect, or during a reconnection attempt.","commonSituations":"Automation script tries to send a key combination immediately after calling Connect without waiting for the LoginCompleted event, or the RDP session dropped and the caller hasn't detected it yet.","solutions":["Await the LoginCompleted event (or poll ConnectedState == 1 with a timeout) before sending shortcuts.","Register a handler for OnDisconnected to suppress shortcut-sending until reconnected.","Surface a user-facing message that the child session isn't ready rather than throwing into automation logic."],"exampleFix":"// before\nprivate void SendShortcut(KeyStroke[] strokes, string displayName)\n{\n    if (ConnectedState != 1)\n        throw new InvalidOperationException($\"桌面分身尚未完全连接，无法发送 {displayName}。\");\n    ...\n}\n\n// after — wait for connection or return false\nprivate async Task<bool> SendShortcutAsync(KeyStroke[] strokes, string displayName, CancellationToken ct)\n{\n    using var linked = CancellationTokenSource.CreateLinkedTokenSource(ct);\n    linked.CancelAfter(TimeSpan.FromSeconds(10));\n    while (ConnectedState != 1)\n    {\n        await Task.Delay(200, linked.Token);\n    }\n    SendShortcutCore(strokes, displayName);\n    return true;\n}","handlingStrategy":"validation","validationCode":"// Check connection state before sending\nif (ConnectedState != 1)\n    throw new InvalidOperationException(\"桌面分身尚未完全连接\");\n// Or: await WaitForConnectionAsync(timeout)","typeGuard":"bool IsFullyConnected() => IsHandleCreated && ConnectedState == 1;","tryCatchPattern":"try { SendShortcut(strokes, \"Win+Tab\"); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"尚未完全连接\"))\n{\n    // notify user / queue for retry after LoginCompleted\n}","preventionTips":["Only call SendShortcut after the LoginCompleted event fires.","Register an OnDisconnected handler to set a 'shortcuts disabled' flag.","Implement a connection-state gate in the automation layer."],"tags":["rdp","child-session","state-guard","keyboard"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}