本文介绍了UI自动化:如何更改水平滚动条AutomationElement的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图水平滚动条的值更改为-​​1到-2。
我能够访问它..但接下来,我必须改变它的值。

I am trying to change the value of a horizontal scrollbar from -1 to -2.I am able to get access to it.. but next i have to change its value..

AutomationElement _sideBar = _ClickButtonElement.FindFirst(TreeScope.Descendants,新PropertyCondition(AutomationElement.ClassNamePropertyWindowsForms10.SCROLLBAR.app.0.378734a));

_clickButtonElement是滚动条的父窗口的AutomationElement。

_clickButtonElement is the AutomationElement of the parent window of the scrollbar.

推荐答案

滚动条通常支持。使用这样的:

Scrollbars usually support . Use something like:

RangeValuePattern range = scrollbar.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;
range.SetValue(50); // Set to half way point

请注意,通常滚动条标准化为0..100,无论内在价值的。因此,如果滚动条在内部使用的值-5至5,然后滚动条的0中途点实际上将通过RangeValuePattern暴露为50

Note that usually scrollbars are normalized to 0..100, regardless of internal values. So if a scrollbar internally uses values -5 to 5, then the scrollbar's half-way point of 0 will actually be exposed via RangeValuePattern as 50.

您可能需要使用的,以确保您得到正确的元素,而且它也支持这种模式。您还可以使用检查通过它的UI叫RangeValue.SetValue()你写的任何code之前。

You might want to use the Inspect tool to ensure that you are getting the correct element, and that it also supports this pattern. You can also use Inspect to call RangeValue.SetValue() through its UI before you write any code.

这篇关于UI自动化:如何更改水平滚动条AutomationElement的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 02:13