gpt4 book ai didi

c# - WPF在按钮上播放 “Click”动画。模拟代码点击

转载 作者:行者123 更新时间:2023-12-03 10:59:50 25 4
gpt4 key购买 nike

我有10个默认WPF按钮。

在某些特定情况下,我必须模拟/播放 View 模型中单击按钮的动画。 (演示模式下的应用程序,并向用户演示其工作方式。)

我不知道如何模仿默认的按钮单击,有什么想法吗?

最佳答案

您将需要UI自动化框架(System.Windows.Automation)才能通过代码单击按钮。

var element = AutomationElement.RootElement.FindFirst(
TreeScope.Descendants,
new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), new PropertyCondition(AutomationElement.NameProperty, "Start", PropertyConditionFlags.IgnoreCase))
);
var pattern = (InvokePattern)element.GetCurrentPattern(InvokePattern.Pattern);
pattern.Invoke();

此代码将单击WPF应用程序的Windows开始按钮。您可以以相同的方式在应用程序中搜索按钮。

所需引用:UIAutomationClient,UIAutomationTypes

关于c# - WPF在按钮上播放 “Click”动画。模拟代码点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17744529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com