mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[PowerToys Run] Add Suport for Commandline arguments in Program Plugin (#5791)
* Implemented possibility to add commandline arguments in the Program Plugin * Add missing return statement inc ommandArgumentParser loop * Fix typos * Fix Additional Typo * Changed -c to /c to make it a valid cmd argument * Added small comment about importance of order in _programArgumentParsers Co-authored-by: Roy <royvou@hotmailcom>
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
{
|
||||
List<ContextMenuResult> ContextMenus(IPublicAPI api);
|
||||
|
||||
Result Result(string query, IPublicAPI api);
|
||||
Result Result(string query, string queryArguments, IPublicAPI api);
|
||||
|
||||
string UniqueIdentifier { get; set; }
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return Properties.Resources.powertoys_run_plugin_program_packaged_application;
|
||||
}
|
||||
|
||||
public Result Result(string query, IPublicAPI api)
|
||||
public Result Result(string query, string queryArguments, IPublicAPI api)
|
||||
{
|
||||
if (api == null)
|
||||
{
|
||||
@@ -100,7 +100,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
ContextData = this,
|
||||
Action = e =>
|
||||
{
|
||||
Launch(api);
|
||||
Launch(api, queryArguments);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
@@ -195,16 +195,15 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentially keeping the process alive, and showing the user an error message")]
|
||||
private async void Launch(IPublicAPI api)
|
||||
private async void Launch(IPublicAPI api, string queryArguments)
|
||||
{
|
||||
var appManager = new ApplicationActivationHelper.ApplicationActivationManager();
|
||||
const string noArgs = "";
|
||||
const ApplicationActivationHelper.ActivateOptions noFlags = ApplicationActivationHelper.ActivateOptions.None;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
appManager.ActivateApplication(UserModelId, noArgs, noFlags, out uint unusedPid);
|
||||
appManager.ActivateApplication(UserModelId, queryArguments, noFlags, out var unusedPid);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// 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.
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result Result(string query, IPublicAPI api)
|
||||
public Result Result(string query, string queryArguments, IPublicAPI api)
|
||||
{
|
||||
if (api == null)
|
||||
{
|
||||
@@ -225,6 +225,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
FileName = LnkResolvedPath ?? FullPath,
|
||||
WorkingDirectory = ParentDirectory,
|
||||
UseShellExecute = true,
|
||||
Arguments = queryArguments,
|
||||
};
|
||||
|
||||
Main.StartProcess(Process.Start, info);
|
||||
|
||||
Reference in New Issue
Block a user