问题描述
在基于自动化的项目中,我使用以下代码来自动化另一个应用程序。之前它运行良好,但现在它非常频繁地显示“操作超时”错误(10 次尝试中有 9 次)。
我不明白为什么会这样:(
这是代码
Public Shared Sub SetwindowTexBoxText(WindowHandle As Integer,ObjectID As String,ObjectName As String,Value As String)
Dim baseElement As AutomationElement
baseElement = AutomationElement.FromHandle(New system.intPtr(WindowHandle))
Dim oCurPattern As Object
For Each oElement As AutomationElement In baseElement.FindAll(TreeScope.Descendants,New PropertyCondition(AutomationElement.AutomationIdProperty,ObjectID))
If oElement.Current.Name = ObjectName Then
oCurPattern = nothing
If oElement.TryGetCurrentPattern(Windows.Automation.ValuePattern.Pattern,oCurPattern) = True Then
CType(oCurPattern,System.Windows.Automation.ValuePattern).SetValue(Value) //error throws on this line
End If
Exit For
End If
Next
End Sub
最好的问候
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)