diff --git a/src/RunnerV2/RunnerV2/Helpers/AIHelper.cs b/src/RunnerV2/RunnerV2/Helpers/AIHelper.cs new file mode 100644 index 0000000000..74d748a7da --- /dev/null +++ b/src/RunnerV2/RunnerV2/Helpers/AIHelper.cs @@ -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(); + 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(); + } + } +} diff --git a/src/RunnerV2/RunnerV2/ModuleInterfaces/ImageResizerModuleInterface.cs b/src/RunnerV2/RunnerV2/ModuleInterfaces/ImageResizerModuleInterface.cs index 272c16efcc..f2eb95c480 100644 --- a/src/RunnerV2/RunnerV2/ModuleInterfaces/ImageResizerModuleInterface.cs +++ b/src/RunnerV2/RunnerV2/ModuleInterfaces/ImageResizerModuleInterface.cs @@ -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); diff --git a/src/RunnerV2/RunnerV2/Program.cs b/src/RunnerV2/RunnerV2/Program.cs index ad4e1c881e..968759e685 100644 --- a/src/RunnerV2/RunnerV2/Program.cs +++ b/src/RunnerV2/RunnerV2/Program.cs @@ -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().Startup); Action afterInitializationAction = () => { };