You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用FlaUI与C#自动化安装程序时,点击按钮报错的解决方案

FlaUI自动化安装程序按钮点击异常解决求助

我使用C#和FlaUI自动化某应用程序的安装流程,已成功将目标程序窗口前置并设置焦点。通过FlaUInspect v1.3.0获取到按钮名称为"Next >",遍历所有按钮时能通过弹窗确认找到该按钮,但调用b.Click()方法时抛出异常:

FlaUI.Core.Exceptions.NoClickablePointException: Exception of type 'FlaUI.Core.Exceptions.NoClickablePointException' was thrown.

参考相关论坛建议改用Invoke()方法,却又抛出异常:

System.InvalidOperationException: Operation is not valid due to the current state of the object.

现寻求可行的按钮点击方法,相关代码如下:

using (var automation = new UIA2Automation())
{   
    var mainWindow = application.GetMainWindow(automation);

    if (mainWindow != null)
    {
        mainWindow.SetForeground();
        mainWindow.Focus();
        var buttons = mainWindow.FindAllDescendants(x => x.ByControlType(FlaUI.Core.Definitions.ControlType.Button));
        foreach (var b in buttons)
        {
         if (b.Name == "Next >")
            {
                MessageBox.Show("found: " + b.Name);
                //I'm using click OR invoke, not both. Including both as reference
                b.Click();
                
                var invokePattern = b.Patterns.Invoke.Pattern;                           
                invokePattern.Invoke();
            }           
        }
    }
}

附:确认找到按钮的弹窗截图、目标按钮的FlaUInspect输出截图

内容的提问来源于stack exchange,提问作者Fuzz Evans

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 16:42:51