Files
PowerToys/src/Runner/ModuleInterfaces/PowerToysRunModuleInterface.cs

61 lines
2.4 KiB
C#
Raw Normal View History

2025-12-21 23:40:58 +01:00
// 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;
using System.Collections.Generic;
2025-12-22 22:38:29 +01:00
using System.IO;
2025-12-21 23:40:58 +01:00
using Microsoft.PowerToys.Settings.UI.Library;
using PowerToys.GPOWrapper;
using PowerToys.Interop;
using RunnerV2.Models;
namespace RunnerV2.ModuleInterfaces
{
2026-02-20 17:16:27 +01:00
internal sealed class PowerToysRunModuleInterface : ProcessModuleAbstractClass, IPowerToysModule, IPowerToysModuleShortcutsProvider, IPowerToysModuleSettingsChangedSubscriber
2025-12-21 23:40:58 +01:00
{
public string Name => "PowerToys Run";
public bool Enabled => SettingsUtils.Default.GetSettings<GeneralSettings>().Enabled.PowerLauncher;
public GpoRuleConfigured GpoRuleConfigured => GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
2025-12-22 22:38:29 +01:00
public override string ProcessPath => Path.GetFullPath("PowerToys.PowerLauncher.exe");
2025-12-21 23:40:58 +01:00
public override string ProcessName => "PowerToys.PowerLauncher";
2025-12-22 22:38:29 +01:00
public override ProcessLaunchOptions LaunchOptions => ProcessLaunchOptions.ElevateIfApplicable | ProcessLaunchOptions.SingletonProcess;
2025-12-21 23:40:58 +01:00
2025-12-22 22:38:29 +01:00
public override string ProcessArguments => $"-powerToysPid {Environment.ProcessId}";
2025-12-21 23:40:58 +01:00
public void Disable()
{
using var terminateEvent = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, Constants.RunExitEvent());
terminateEvent.Set();
}
public void Enable()
{
}
2026-02-20 17:16:27 +01:00
public void OnSettingsChanged()
{
using var settingsChangedEvent = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, Constants.RunSendSettingsTelemetryEvent());
settingsChangedEvent.Set();
}
2025-12-22 22:38:29 +01:00
public List<(HotkeySettings Hotkey, Action Action)> Shortcuts =>
[
2026-02-20 17:16:27 +01:00
/*(
2025-12-21 23:40:58 +01:00
SettingsUtils.Default.GetSettings<PowerLauncherSettings>(Name).Properties.OpenPowerLauncher,
() =>
{
EnsureLaunched();
using var invokeRunEvent = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, Constants.PowerLauncherCentralizedHookSharedEvent());
invokeRunEvent.Set();
}
2026-02-20 17:16:27 +01:00
),*/
2025-12-22 22:38:29 +01:00
];
2025-12-21 23:40:58 +01:00
}
}