mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
Implement AI detection
This commit is contained in:
40
src/RunnerV2/RunnerV2/Helpers/AIHelper.cs
Normal file
40
src/RunnerV2/RunnerV2/Helpers/AIHelper.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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 = () => { };
|
||||
|
||||
Reference in New Issue
Block a user