mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-18 16:41:36 -07:00
Fix custom integration autoclosing not working
This commit is contained in:
parent
9fd4c367fb
commit
719fbb898e
11
Bloxstrap/Resources/Strings.Designer.cs
generated
11
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -2528,15 +2528,6 @@ namespace Bloxstrap.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to e.g. C:\Windows\System32\cmd.exe.
|
||||
/// </summary>
|
||||
public static string Menu_Integrations_Custom_AppLocation_Placeholder {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.Integrations.Custom.AppLocation.Placeholder", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Auto close when Roblox closes.
|
||||
/// </summary>
|
||||
@ -2565,7 +2556,7 @@ namespace Bloxstrap.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to e.g. /k echo Roblox is running!.
|
||||
/// Looks up a localized string similar to Roblox is running!.
|
||||
/// </summary>
|
||||
public static string Menu_Integrations_Custom_LaunchArgs_Placeholder {
|
||||
get {
|
||||
|
@ -727,9 +727,6 @@ Selecting 'No' will ignore this warning and continue installation.</value>
|
||||
<data name="Menu.Integrations.Custom.AppLocation" xml:space="preserve">
|
||||
<value>Application Location</value>
|
||||
</data>
|
||||
<data name="Menu.Integrations.Custom.AppLocation.Placeholder" xml:space="preserve">
|
||||
<value>e.g. C:\Windows\System32\cmd.exe</value>
|
||||
</data>
|
||||
<data name="Menu.Integrations.Custom.AutoClose" xml:space="preserve">
|
||||
<value>Auto close when Roblox closes</value>
|
||||
</data>
|
||||
@ -740,7 +737,7 @@ Selecting 'No' will ignore this warning and continue installation.</value>
|
||||
<value>Launch Arguments</value>
|
||||
</data>
|
||||
<data name="Menu.Integrations.Custom.LaunchArgs.Placeholder" xml:space="preserve">
|
||||
<value>e.g. /k echo Roblox is running!</value>
|
||||
<value>Roblox is running!</value>
|
||||
</data>
|
||||
<data name="Menu.Integrations.Custom.NewIntegration" xml:space="preserve">
|
||||
<value>New Integration</value>
|
||||
|
@ -95,11 +95,11 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBox Grid.Column="0" Margin="0,0,0,0" PlaceholderText="{x:Static resources:Strings.Menu_Integrations_Custom_AppLocation_Placeholder}" Text="{Binding SelectedCustomIntegration.Location}" />
|
||||
<ui:TextBox Grid.Column="0" Margin="0,0,0,0" PlaceholderText="C:\Windows\System32\cmd.exe" Text="{Binding SelectedCustomIntegration.Location}" />
|
||||
<ui:Button Grid.Column="1" Margin="8,0,0,0" Height="34" Icon="Folder24" Content="{x:Static resources:Strings.Common_Browse}" Command="{Binding BrowseIntegrationLocationCommand}" />
|
||||
</Grid>
|
||||
<TextBlock Margin="0,8,0,0" Text="{x:Static resources:Strings.Menu_Integrations_Custom_LaunchArgs}" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||
<ui:TextBox Margin="0,4,0,0" PlaceholderText="{x:Static resources:Strings.Menu_Integrations_Custom_LaunchArgs_Placeholder}" Text="{Binding SelectedCustomIntegration.LaunchArgs}" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" />
|
||||
<ui:TextBox Margin="0,4,0,0" PlaceholderText="{Binding Source='/k echo {0}', Converter={StaticResource StringFormatConverter}, ConverterParameter={x:Static resources:Strings.Menu_Integrations_Custom_LaunchArgs_Placeholder}}" Text="{Binding SelectedCustomIntegration.LaunchArgs}" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" />
|
||||
<CheckBox Margin="0,8,0,0" Content="{x:Static resources:Strings.Menu_Integrations_Custom_AutoClose}" IsChecked="{Binding SelectedCustomIntegration.AutoClose}" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" Text="{x:Static resources:Strings.Menu_Integrations_Custom_NoneSelected}" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Bloxstrap.Integrations;
|
||||
using System.CodeDom;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace Bloxstrap
|
||||
{
|
||||
@ -54,7 +52,7 @@ namespace Bloxstrap
|
||||
|
||||
if (split.Length >= 2)
|
||||
{
|
||||
foreach (string strPid in split[0].Split(';'))
|
||||
foreach (string strPid in split[1].Split(','))
|
||||
{
|
||||
if (int.TryParse(strPid, out int pid) && pid != 0)
|
||||
_autoclosePids.Add(pid);
|
||||
@ -86,38 +84,33 @@ namespace Bloxstrap
|
||||
_notifyIcon = new(this);
|
||||
}
|
||||
|
||||
public void KillRobloxProcess() => KillProcess(_gameClientPid);
|
||||
public void KillRobloxProcess() => CloseProcess(_gameClientPid, true);
|
||||
|
||||
public void KillProcess(int pid)
|
||||
public void CloseProcess(int pid, bool force = false)
|
||||
{
|
||||
const string LOG_IDENT = "Watcher::CloseProcess";
|
||||
try
|
||||
{
|
||||
using var process = Process.GetProcessById(pid);
|
||||
|
||||
App.Logger.WriteLine("Watcher::KillProcess", $"Killing process '{process.ProcessName}' (PID {process.Id})");
|
||||
App.Logger.WriteLine(LOG_IDENT, $"Killing process '{process.ProcessName}' (pid={pid}, force={force})");
|
||||
|
||||
if (process.HasExited)
|
||||
{
|
||||
App.Logger.WriteLine("Watcher::KillProcess", $"PID {process.Id} has already exited");
|
||||
App.Logger.WriteLine(LOG_IDENT, $"PID {pid} has already exited");
|
||||
return;
|
||||
}
|
||||
|
||||
if (force)
|
||||
process.Kill();
|
||||
process.Close();
|
||||
}
|
||||
|
||||
public void CloseProcess(int pid)
|
||||
{
|
||||
using var process = Process.GetProcessById(pid);
|
||||
|
||||
App.Logger.WriteLine("Watcher::CloseProcess", $"Closing process '{process.ProcessName}' (PID {process.Id})");
|
||||
|
||||
if (process.HasExited)
|
||||
{
|
||||
App.Logger.WriteLine("Watcher::CloseProcess", $"PID {process.Id} has already exited");
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
process.CloseMainWindow();
|
||||
process.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.Logger.WriteLine(LOG_IDENT, $"PID {pid} could not be closed");
|
||||
App.Logger.WriteException(LOG_IDENT, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Run()
|
||||
|
Loading…
Reference in New Issue
Block a user