mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add run as administration when holding ctrl and shift to Program and Explorer plugins
This commit is contained in:
parent
a87cea7e6f
commit
ffd22d78c2
3 changed files with 34 additions and 4 deletions
|
|
@ -46,6 +46,7 @@
|
|||
<KeyBinding Key="Home" Modifiers="Alt" Command="{Binding SelectFirstResultCommand}"></KeyBinding>
|
||||
<KeyBinding Key="O" Modifiers="Ctrl" Command="{Binding LoadContextMenuCommand}"></KeyBinding>
|
||||
<KeyBinding Key="H" Modifiers="Ctrl" Command="{Binding LoadHistoryCommand}"></KeyBinding>
|
||||
<KeyBinding Key="Enter" Modifiers="Ctrl+Shift" Command="{Binding OpenResultCommand}"></KeyBinding>
|
||||
<KeyBinding Key="Enter" Modifiers="Shift" Command="{Binding LoadContextMenuCommand}"></KeyBinding>
|
||||
<KeyBinding Key="Enter" Command="{Binding OpenResultCommand}"></KeyBinding>
|
||||
<KeyBinding Key="Enter" Modifiers="Ctrl" Command="{Binding OpenResultCommand}"></KeyBinding>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Search
|
||||
|
|
@ -127,7 +129,26 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
try
|
||||
{
|
||||
if (c.SpecialKeyState.CtrlPressed)
|
||||
if (File.Exists(filePath) && c.SpecialKeyState.CtrlPressed && c.SpecialKeyState.ShiftPressed)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = filePath,
|
||||
UseShellExecute = true,
|
||||
Verb = "runas",
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Could not start " + filePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (c.SpecialKeyState.CtrlPressed)
|
||||
{
|
||||
FilesFolders.OpenContainingFolder(filePath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,16 +102,24 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
Score = matchResult.Score,
|
||||
TitleHighlightData = matchResult.MatchData,
|
||||
ContextData = this,
|
||||
Action = _ =>
|
||||
Action = c =>
|
||||
{
|
||||
var runAsAdmin = (
|
||||
c.SpecialKeyState.CtrlPressed &&
|
||||
c.SpecialKeyState.ShiftPressed &&
|
||||
!c.SpecialKeyState.AltPressed &&
|
||||
!c.SpecialKeyState.WinPressed
|
||||
);
|
||||
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = LnkResolvedPath ?? FullPath,
|
||||
WorkingDirectory = ParentDirectory,
|
||||
UseShellExecute = true
|
||||
UseShellExecute = true,
|
||||
Verb = runAsAdmin ? "runas" : null
|
||||
};
|
||||
|
||||
Main.StartProcess(Process.Start, info);
|
||||
Task.Run(() => Main.StartProcess(Process.Start, info));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue