mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Users can now use Ctrl+P to toggle pinning and unpinning applications from the top of the All Apps extension. This pinned status persists through restarts & reboots. https://github.com/user-attachments/assets/86895a38-7312-438a-9409-b50a85979d12 Reference: #40543 --------- Co-authored-by: Mike Griese <migrie@microsoft.com>
55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
// 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.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using ManagedCommon;
|
|
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
|
using Microsoft.CmdPal.Ext.Apps.Properties;
|
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
|
|
|
internal sealed partial class OpenInConsoleCommand : InvokableCommand
|
|
{
|
|
private readonly string _target;
|
|
|
|
public OpenInConsoleCommand(string target)
|
|
{
|
|
Name = Resources.open_path_in_console;
|
|
Icon = Icons.OpenConsoleIcon;
|
|
|
|
_target = target;
|
|
}
|
|
|
|
internal static async Task LaunchTarget(string t)
|
|
{
|
|
await Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
var processStartInfo = new ProcessStartInfo
|
|
{
|
|
WorkingDirectory = t,
|
|
FileName = "cmd.exe",
|
|
};
|
|
|
|
Process.Start(processStartInfo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogError(ex.Message);
|
|
}
|
|
});
|
|
}
|
|
|
|
public override CommandResult Invoke()
|
|
{
|
|
_ = LaunchTarget(_target).ConfigureAwait(false);
|
|
|
|
return CommandResult.Dismiss();
|
|
}
|
|
}
|