网页使用javascript来构建其html所以我需要支持js的html解析器.
我发现了角度锐利,但我不能让它起作用.
using AngleSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace AngleSharpScraping
{
class Program
{
static void Main(string[] args)
{
GetMkvToolNix();
Console.ReadKey();
}
static async void GetMkvToolNix()
{
// Create a new configuration with javascript interpreter.
var config = new Configuration().WithJavaScript();
// Parsing process.
var document = await BrowsingContext.New(config).OpenAsync(Url.Create("http://www.fosshub.com/MKVToolNix.html"));
var link = document.QuerySelector("body > div.container.page-content > div > div.col-sm-9 > article > div.main-dl-box > p:nth-child(2) > a.dwl-link.xlink").GetAttribute("data");
Console.WriteLine(link);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我从 pip 安装了最后一个 pywinauto 模块。
我不知道如何使用 Check()、UnCheck()、GetCheckState() 方法。
这是我非常简单的代码示例。
from pywinauto import application
# Start the madvr settings application.
app = application.Application()
app.start_(r'C:\Program Files\LAV Filters\x86\madVR\madHcCtrl.exe editLocalSettingsDontWait')
# Handle the madvr settings window.
madvr = app.window_(title_re="madVR.*")
# Enable the smooth motion tab.
madvr.TreeView.GetItem(r'\rendering\smooth motion').Click()
# Check the smooth motion checkbox.
madvr.TCheckBox.Check()
Run Code Online (Sandbox Code Playgroud)
如果我使用 Click() 方法,它会起作用,但这不是我想要的。
madvr.TCheckBox.Click()
Run Code Online (Sandbox Code Playgroud)
如果该复选框已被选中,则会取消选中它。
为什么我不能使用 Check() 方法?
我尝试使用 Uncheck() 和 GetCheckState() 方法,它们也不起作用。
这是我的 XAML 部分代码:
<DockPanel Margin="1 5 1 0" Height="25">
<Button DockPanel.Dock="Right" Width="70" Margin="6 0 0 0" Content="Install" Click="Install" />
<Button DockPanel.Dock="Right" Width="70" Margin="6 0 0 0" Content="Uninstall"/>
<ProgressBar Name="progressBar"/>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
这是安装方法:
private void Install(object sender, RoutedEventArgs e)
{
progressBar.Value = 5;
installer.InstallProgram1();
progressBar.Value = 25;
installer.InstallProgram2();
progressBar.Value = 50;
installer.InstallProgram3();
progressBar.Value = 75;
installer.InstallProgram4();
progressBar.Value = 100;
}
Run Code Online (Sandbox Code Playgroud)
当我单击安装按钮时,它运行安装方法但不正确。
- 它从不执行第一行:'progressBar.Value = 5'。
- 第二行效果很好。
- 在没有任何作用之后。
我试图用'MessageBox.Show("Hello World")'替换我的方法,它起作用了,进度条值发生了变化。
但为什么它不适用于我的方法?
为什么“installer.InstallProgram2()”不工作/完成?
我的两种方法,它们在 Installer.cs 文件中:
public void InstallProgram1()
{
// Download …Run Code Online (Sandbox Code Playgroud) 我需要自动化madvr gui并通过uutoutomation实现平滑运动.
但找不到最近和简单的工作样品.

madvr窗口识别:

madvr平滑动作复选框识别:

我的实际代码:
using System;
using System.Diagnostics;
namespace MadAutomation
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Enabling the madvr smooth motion feature...");
EnableSmoothMotion();
Console.Write("Press any key to continue...");
Console.ReadKey(true);
}
public static void EnableSmoothMotion()
{
// Run madvr configuration.
Process p = new Process();
p.StartInfo.FileName = @"C:\Users\Admin\Desktop\madVR\madHcCtrl.exe";
p.StartInfo.Arguments = "editLocalSettingsDontWait";
p.Start();
// Enable smooth motion checkbox.
}
}
}
Run Code Online (Sandbox Code Playgroud)