I need to automate the madvr gui and enable smooth motion with uiautomation.
But can't find recent and easy working samples.
The madvr window identification:
The madvr smooth motion checkbox identification:
My actual code:
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.
}
}
}
Here is a program that does it. Note you must use the NuGet UIAComWrapper package (written by a Microsoft guy) instead of the standard UIAutomation*.dll provided out-of-the-box for it to work. The standard UIA .NET assemblies don't see all AutomationElement, don't know all properties (Aria, etc.).
Yes, it means they are bugged/obsolete and for some reason, Microsoft does not officially ship the newer ones with new .NET or Windows releases... Anyway the UIAComWrapper is a 100% source-compatible drop-in replacement, so that shouldn't be a problem.
If you want to see the differences between what's returned by UIAComWrapper vs UIA asssemblies, it's the same differences that you will see if you use Inspect (the official UIA tool) vs UISpy (the obsolete official UI tool), respectively. They look similar but are in fact quite different in the details or structure.
Note: I used the event handler here instead of process.MainWindowHandle because the main window for the process is not the settings window, and the settings window is not a child of the main window.