【发布时间】:2021-03-22 18:35:28
【问题描述】:
我尝试了下面的代码:
using System;
using System.Diagnostics;
using FlaUI.UIA3;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Process[] AllProcesslist = Process.GetProcesses();
foreach (Process Proc in AllProcesslist)
{
if (!String.IsNullOrEmpty(Proc.MainWindowTitle) && Proc.MainWindowTitle == "Movies & TV")
{
Console.WriteLine("Window Found!");
var app = new FlaUI.Core.Application(Proc);
using (var automation = new UIA3Automation())
{
var window = app.GetMainWindow(automation);
var elem = window.FindFirstDescendant(cf => cf.ByAutomationId("ProgressSlider"));
Console.WriteLine(elem);
elem.Patterns.Scroll.Pattern.SetScrollPercent(20, -1);
}
}
}
Console.Read();
}
}
}
但它返回FlaUI.Core.Exceptions.PatternNotSupportedException: 'The requested pattern 'Scroll [#10004]' is not supported',
我使用了 FlaUInspect,然后我意识到它只支持 ScrollItem 和 RangeValue,
所以我将 elem.Patterns.Scroll.Pattern.SetScrollPercent(20, -1) 更改为 elem.Patterns.ScrollItem.Pattern.SetScrollPercent(20, -1) 但没有 SetScrollPercent。
如何实现自动化?
【问题讨论】: