gpt4 book ai didi

c# - 使用 FlaUI 为电影和电视设置滚动百分比

转载 作者:行者123 更新时间:2023-12-05 06:55:52 29 4
gpt4 key购买 nike

我正在尝试自动化电影和电视流程 slider enter image description here

我尝试了下面的代码:

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。

我怎样才能使它自动化?

最佳答案

我使用 RangeValue 而不是 ScrollItem,现在它可以正常工作了!

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"));
elem.Patterns.RangeValue.Pattern.SetValue(64);
Console.WriteLine(elem.Patterns.RangeValue.Pattern.Value);
}
}
}

Console.Read();
}
}
}

关于c# - 使用 FlaUI 为电影和电视设置滚动百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65249749/

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