fix: reject UI operations when the input desktop is unavailable

This commit is contained in:
2026-09-06 02:14:16 +08:00
parent c35a4a1051
commit 1494094651
9 changed files with 203 additions and 2 deletions
+4
View File
@@ -369,6 +369,7 @@ public static partial class WechatChatClient
}
WechatOperationPolicy.ValidateNames([session], nameof(session));
WechatDesktop.EnsureInputAvailable();
var checkpoint = await ListenerCheckpointStore.LoadAsync(checkpointPath, cancellationToken);
if (checkpoint is not null && !string.Equals(checkpoint.Session, session, StringComparison.Ordinal))
{
@@ -548,6 +549,7 @@ public static partial class WechatChatClient
private static AutomationElement AttachWindow(UIA3Automation automation, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
WechatDesktop.EnsureInputAvailable();
var window = WechatDoctor.FindWechatWindow(automation);
if (window is null || FindByAutomationId(window, WechatLocators.MainView) is null)
{
@@ -814,6 +816,7 @@ public static partial class WechatChatClient
private static void ClickCenter(AutomationElement element)
{
WechatDesktop.EnsureInputAvailable();
var bounds = element.BoundingRectangle;
if (bounds.Width <= 0 || bounds.Height <= 0)
{
@@ -825,6 +828,7 @@ public static partial class WechatChatClient
private static void ExecuteInputStep(string step, Action action)
{
WechatDesktop.EnsureInputAvailable();
try
{
action();