Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
<system:String x:Key="flowlauncher_plugin_cmd_cmd_has_been_executed_times">this command has been executed {0} times</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_execute_through_shell">execute command through command shell</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_run_as_administrator">Run As Administrator</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_copy">Copy the command</system:String>
</ResourceDictionary>
38 changes: 24 additions & 14 deletions Plugins/Flow.Launcher.Plugin.Shell/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Flow.Launcher.Plugin.Shell
public class Main : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable
{
private const string Image = "Images/shell.png";
private PluginInitContext _context;
private PluginInitContext context;
private bool _winRStroked;
private readonly KeyboardSimulator _keyboardSimulator = new KeyboardSimulator(new InputSimulator());

Expand Down Expand Up @@ -108,14 +108,14 @@ private List<Result> GetHistoryCmds(string cmd, Result result)
{
if (m.Key == cmd)
{
result.SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_cmd_cmd_has_been_executed_times"), m.Value);
result.SubTitle = string.Format(context.API.GetTranslation("flowlauncher_plugin_cmd_cmd_has_been_executed_times"), m.Value);
return null;
}

var ret = new Result
{
Title = m.Key,
SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_cmd_cmd_has_been_executed_times"), m.Value),
SubTitle = string.Format(context.API.GetTranslation("flowlauncher_plugin_cmd_cmd_has_been_executed_times"), m.Value),
IcoPath = Image,
Action = c =>
{
Expand All @@ -134,7 +134,7 @@ private Result GetCurrentCmd(string cmd)
{
Title = cmd,
Score = 5000,
SubTitle = _context.API.GetTranslation("flowlauncher_plugin_cmd_execute_through_shell"),
SubTitle = context.API.GetTranslation("flowlauncher_plugin_cmd_execute_through_shell"),
IcoPath = Image,
Action = c =>
{
Expand All @@ -152,7 +152,7 @@ private List<Result> ResultsFromlHistory()
.Select(m => new Result
{
Title = m.Key,
SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_cmd_cmd_has_been_executed_times"), m.Value),
SubTitle = string.Format(context.API.GetTranslation("flowlauncher_plugin_cmd_cmd_has_been_executed_times"), m.Value),
IcoPath = Image,
Action = c =>
{
Expand Down Expand Up @@ -234,13 +234,13 @@ private void Execute(Func<ProcessStartInfo, Process> startProcess,ProcessStartIn
{
var name = "Plugin: Shell";
var message = $"Command not found: {e.Message}";
_context.API.ShowMsg(name, message);
context.API.ShowMsg(name, message);
}
catch(Win32Exception e)
{
var name = "Plugin: Shell";
var message = $"Error running the command: {e.Message}";
_context.API.ShowMsg(name, message);
context.API.ShowMsg(name, message);
}
}

Expand Down Expand Up @@ -275,7 +275,7 @@ private bool ExistInPath(string filename)

public void Init(PluginInitContext context)
{
this._context = context;
this.context = context;
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent;
}

Expand All @@ -301,7 +301,7 @@ bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state)

private void OnWinRPressed()
{
_context.API.ChangeQuery($"{_context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeperater}");
context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeperater}");
Application.Current.MainWindow.Visibility = Visibility.Visible;
}

Expand All @@ -312,12 +312,12 @@ public Control CreateSettingPanel()

public string GetTranslatedPluginTitle()
{
return _context.API.GetTranslation("flowlauncher_plugin_cmd_plugin_name");
return context.API.GetTranslation("flowlauncher_plugin_cmd_plugin_name");
}

public string GetTranslatedPluginDescription()
{
return _context.API.GetTranslation("flowlauncher_plugin_cmd_plugin_description");
return context.API.GetTranslation("flowlauncher_plugin_cmd_plugin_description");
}

public List<Result> LoadContextMenus(Result selectedResult)
Expand All @@ -326,7 +326,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
{
new Result
{
Title = _context.API.GetTranslation("flowlauncher_plugin_cmd_run_as_different_user"),
Title = context.API.GetTranslation("flowlauncher_plugin_cmd_run_as_different_user"),
Action = c =>
{
Task.Run(() =>Execute(ShellCommand.RunAsDifferentUser, PrepareProcessStartInfo(selectedResult.Title)));
Expand All @@ -336,13 +336,23 @@ public List<Result> LoadContextMenus(Result selectedResult)
},
new Result
{
Title = _context.API.GetTranslation("flowlauncher_plugin_cmd_run_as_administrator"),
Title = context.API.GetTranslation("flowlauncher_plugin_cmd_run_as_administrator"),
Action = c =>
{
Execute(Process.Start, PrepareProcessStartInfo(selectedResult.Title, true));
return true;
},
IcoPath = Image
IcoPath = "Images/admin.png"
},
new Result
{
Title = context.API.GetTranslation("flowlauncher_plugin_cmd_copy"),
Action = c =>
{
Clipboard.SetDataObject(selectedResult.Title);
return true;
},
IcoPath = "Images/copy.png"
}
};

Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Shell/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Name": "Shell",
"Description": "Provide executing commands from Flow Launcher. Commands should start with >",
"Author": "qianlifeng",
"Version": "1.1.2",
"Version": "1.2.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Shell.dll",
Expand Down