Implement AI detection

This commit is contained in:
Noraa Junker
2026-02-12 02:37:57 +01:00
parent e2b8790220
commit c6e7dfd5cd
3 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
using System.IO;
using System.Threading;
using Microsoft.PowerToys.Settings.UI.Library;
namespace RunnerV2.Helpers
{
internal static class AIHelper
{
public static void DetectAiCapabilities(bool skipSettingsCheck = false)
{
new Thread(() => DetectAiCapabilitiesInternal(skipSettingsCheck)).Start();
}
private static void DetectAiCapabilitiesInternal(bool skipSettingsCheck)
{
if (!skipSettingsCheck)
{
var generalSettings = SettingsUtils.Default.GetSettings<GeneralSettings>();
if (!generalSettings.Enabled.ImageResizer)
{
return;
}
}
if (!Path.Exists("WinUI3Apps\\PowerToys.ImageResizer.exe"))
{
return;
}
var p = Process.Start("WinUI3Apps\\PowerToys.ImageResizer.exe", "--detect-ai");
p.WaitForExit(30000);
p.Close();
}
}
}

View File

@@ -29,6 +29,7 @@ namespace RunnerV2.ModuleInterfaces
public void Enable()
{
UpdateImageResizerRegistrationWin10(true);
AIHelper.DetectAiCapabilities(true);
if (Environment.OSVersion.Version.Build >= 22000)
{
PackageHelper.InstallPackage(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "WinUI3Apps", "ImageResizerContextMenuPackage.msix"), [], true);

View File

@@ -89,6 +89,12 @@ internal sealed class Program
bool hasRestartedElevatedArgment = args.Contains("--restartedElevated");
// When running on Windows 11, detect AI capabilities and log them.
if (Environment.OSVersion.Version.Build >= 22000)
{
AIHelper.DetectAiCapabilities();
}
AutoStartHelper.SetAutoStartState(SettingsUtils.Default.GetSettings<GeneralSettings>().Startup);
Action afterInitializationAction = () => { };