fix: reject UI operations when the input desktop is unavailable
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user