mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2410 from flooxo/shell_fix
New option CloseShellAfterPress
This commit is contained in:
commit
06e3452455
5 changed files with 36 additions and 7 deletions
|
|
@ -3,6 +3,8 @@
|
|||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_relace_winr">Replace Win+R</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_close_cmd_after_press">Close Command Prompt after pressing any key</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_press_any_key_to_close">Press any key to close this window...</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">Do not close Command Prompt after command execution</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Always run as administrator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Run as different user</system:String>
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
case Shell.Cmd:
|
||||
{
|
||||
info.FileName = "cmd.exe";
|
||||
info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command}";
|
||||
info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? $"&& echo {context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")} && pause > nul /c" : "")}";
|
||||
|
||||
//// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing.
|
||||
//// Previous code using ArgumentList, commands needed to be separated correctly:
|
||||
|
|
@ -232,7 +232,7 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
else
|
||||
{
|
||||
info.ArgumentList.Add("-Command");
|
||||
info.ArgumentList.Add(command);
|
||||
info.ArgumentList.Add($"{command}; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'; [System.Console]::ReadKey(); exit" : "")}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
info.ArgumentList.Add("-NoExit");
|
||||
}
|
||||
info.ArgumentList.Add("-Command");
|
||||
info.ArgumentList.Add(command);
|
||||
info.ArgumentList.Add($"{command}; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'; [System.Console]::ReadKey(); exit" : "")}");
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
public Shell Shell { get; set; } = Shell.Cmd;
|
||||
|
||||
public bool ReplaceWinR { get; set; } = false;
|
||||
|
||||
public bool CloseShellAfterPress { get; set; } = false;
|
||||
|
||||
public bool LeaveShellOpen { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox
|
||||
x:Name="ReplaceWinR"
|
||||
|
|
@ -23,20 +24,26 @@
|
|||
HorizontalAlignment="Left"
|
||||
Content="{DynamicResource flowlauncher_plugin_cmd_relace_winr}" />
|
||||
<CheckBox
|
||||
x:Name="LeaveShellOpen"
|
||||
x:Name="CloseShellAfterPress"
|
||||
Grid.Row="1"
|
||||
Margin="10,5,5,5"
|
||||
HorizontalAlignment="Left"
|
||||
Content="{DynamicResource flowlauncher_plugin_cmd_close_cmd_after_press}" />
|
||||
<CheckBox
|
||||
x:Name="LeaveShellOpen"
|
||||
Grid.Row="2"
|
||||
Margin="10,5,5,5"
|
||||
HorizontalAlignment="Left"
|
||||
Content="{DynamicResource flowlauncher_plugin_cmd_leave_cmd_open}" />
|
||||
<CheckBox
|
||||
x:Name="AlwaysRunAsAdministrator"
|
||||
Grid.Row="2"
|
||||
Grid.Row="3"
|
||||
Margin="10,5,5,5"
|
||||
HorizontalAlignment="Left"
|
||||
Content="{DynamicResource flowlauncher_plugin_cmd_always_run_as_administrator}" />
|
||||
<ComboBox
|
||||
x:Name="ShellComboBox"
|
||||
Grid.Row="3"
|
||||
Grid.Row="4"
|
||||
Margin="10,5,5,5"
|
||||
HorizontalAlignment="Left">
|
||||
<ComboBoxItem>CMD</ComboBoxItem>
|
||||
|
|
@ -44,7 +51,7 @@
|
|||
<ComboBoxItem>Pwsh</ComboBoxItem>
|
||||
<ComboBoxItem>RunCommand</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<StackPanel Grid.Row="4" Orientation="Horizontal">
|
||||
<StackPanel Grid.Row="5" Orientation="Horizontal">
|
||||
<CheckBox
|
||||
x:Name="ShowOnlyMostUsedCMDs"
|
||||
Margin="10,5,5,5"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re)
|
||||
{
|
||||
ReplaceWinR.IsChecked = _settings.ReplaceWinR;
|
||||
|
||||
CloseShellAfterPress.IsChecked = _settings.CloseShellAfterPress;
|
||||
|
||||
LeaveShellOpen.IsChecked = _settings.LeaveShellOpen;
|
||||
|
||||
|
|
@ -38,14 +40,30 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
_settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem;
|
||||
}
|
||||
|
||||
CloseShellAfterPress.Checked += (o, e) =>
|
||||
{
|
||||
_settings.CloseShellAfterPress = true;
|
||||
LeaveShellOpen.IsChecked = false;
|
||||
LeaveShellOpen.IsEnabled = false;
|
||||
};
|
||||
|
||||
CloseShellAfterPress.Unchecked += (o, e) =>
|
||||
{
|
||||
_settings.CloseShellAfterPress = false;
|
||||
LeaveShellOpen.IsEnabled = true;
|
||||
};
|
||||
|
||||
LeaveShellOpen.Checked += (o, e) =>
|
||||
{
|
||||
_settings.LeaveShellOpen = true;
|
||||
CloseShellAfterPress.IsChecked = false;
|
||||
CloseShellAfterPress.IsEnabled = false;
|
||||
};
|
||||
|
||||
LeaveShellOpen.Unchecked += (o, e) =>
|
||||
{
|
||||
_settings.LeaveShellOpen = false;
|
||||
CloseShellAfterPress.IsEnabled = true;
|
||||
};
|
||||
|
||||
AlwaysRunAsAdministrator.Checked += (o, e) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue