Skip to content

Commit c6e7dfd

Browse files
committed
Implement AI detection
1 parent e2b8790 commit c6e7dfd

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation
2+
// The Microsoft Corporation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Diagnostics;
6+
using System.IO;
7+
using System.Threading;
8+
using Microsoft.PowerToys.Settings.UI.Library;
9+
10+
namespace RunnerV2.Helpers
11+
{
12+
internal static class AIHelper
13+
{
14+
public static void DetectAiCapabilities(bool skipSettingsCheck = false)
15+
{
16+
new Thread(() => DetectAiCapabilitiesInternal(skipSettingsCheck)).Start();
17+
}
18+
19+
private static void DetectAiCapabilitiesInternal(bool skipSettingsCheck)
20+
{
21+
if (!skipSettingsCheck)
22+
{
23+
var generalSettings = SettingsUtils.Default.GetSettings<GeneralSettings>();
24+
if (!generalSettings.Enabled.ImageResizer)
25+
{
26+
return;
27+
}
28+
}
29+
30+
if (!Path.Exists("WinUI3Apps\\PowerToys.ImageResizer.exe"))
31+
{
32+
return;
33+
}
34+
35+
var p = Process.Start("WinUI3Apps\\PowerToys.ImageResizer.exe", "--detect-ai");
36+
p.WaitForExit(30000);
37+
p.Close();
38+
}
39+
}
40+
}

src/RunnerV2/RunnerV2/ModuleInterfaces/ImageResizerModuleInterface.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public void Disable()
2929
public void Enable()
3030
{
3131
UpdateImageResizerRegistrationWin10(true);
32+
AIHelper.DetectAiCapabilities(true);
3233
if (Environment.OSVersion.Version.Build >= 22000)
3334
{
3435
PackageHelper.InstallPackage(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "WinUI3Apps", "ImageResizerContextMenuPackage.msix"), [], true);

src/RunnerV2/RunnerV2/Program.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ private static void Main(string[] args)
8989

9090
bool hasRestartedElevatedArgment = args.Contains("--restartedElevated");
9191

92+
// When running on Windows 11, detect AI capabilities and log them.
93+
if (Environment.OSVersion.Version.Build >= 22000)
94+
{
95+
AIHelper.DetectAiCapabilities();
96+
}
97+
9298
AutoStartHelper.SetAutoStartState(SettingsUtils.Default.GetSettings<GeneralSettings>().Startup);
9399

94100
Action afterInitializationAction = () => { };

0 commit comments

Comments
 (0)