使用 FlaUI 为电影和电视设置滚动百分比
SetScrollPercent for Movies & TV with FlaUI
我正在尝试自动化电影和电视流程滑块
我尝试了下面的代码:
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();
}
}
}
但是 returns 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();
}
}
}
我正在尝试自动化电影和电视流程滑块
我尝试了下面的代码:
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();
}
}
}
但是 returns 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();
}
}
}