diff --git a/CS2-AutoAccept/CS2-AutoAccept.csproj b/CS2-AutoAccept/CS2-AutoAccept.csproj index b278785..d628c30 100644 --- a/CS2-AutoAccept/CS2-AutoAccept.csproj +++ b/CS2-AutoAccept/CS2-AutoAccept.csproj @@ -12,7 +12,7 @@ True A program to automatically find and press "ACCEPT" for you, when entering a competitive match in CS2. ©️ tsgsOFFICIAL - 2024 - 5.1.5.0 + 5.1.5.1 CS2-AutoAccept diff --git a/CS2-AutoAccept/MainWindow.xaml.cs b/CS2-AutoAccept/MainWindow.xaml.cs index ce01074..d013bec 100644 --- a/CS2-AutoAccept/MainWindow.xaml.cs +++ b/CS2-AutoAccept/MainWindow.xaml.cs @@ -62,7 +62,7 @@ public partial class MainWindow : Window private string _basePath; private string _updatePath; private readonly bool debugMode = false; - public ICommand ToggleWindowCommand { get; } + public ICommand ToggleWindowCommand { get; } public ICommand CloseCommand { get; } private bool _isTrayIconVisible; @@ -78,28 +78,16 @@ public bool IsTrayIconVisible public MainWindow() { InitializeComponent(); + Loaded += MainWindow_Loaded; IsTrayIconVisible = true; DataContext = this; - ToggleWindowCommand = new RelayCommand(o => ToggleWindowState()); + ToggleWindowCommand = new RelayCommand(o => ToggleWindowState()); CloseCommand = new RelayCommand(o => CloseApplication()); // Event handler for double-click on TaskbarIcon MyNotifyIcon.TrayMouseDoubleClick += OnTrayIconDoubleClick; - // Access command line arguments - string[] args = Environment.GetCommandLineArgs(); - - foreach (string arg in args) - { - if (arg.ToLower().Equals("start cs2")) - { - LaunchWeb("steam://rungameid/730"); - Button_LaunchCS.Content = "Launching CS2"; - _gameRunExtraDelay = 15; - } - } - _basePath = Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "CS2 AutoAccept"); _updatePath = Path.Combine(_basePath, "UPDATE"); @@ -218,7 +206,6 @@ public MainWindow() } } #endregion - } private void ToggleWindowState() { @@ -244,6 +231,26 @@ private void UpdateTrayIconVisibility() MyNotifyIcon.Visibility = IsTrayIconVisible ? Visibility.Visible : Visibility.Collapsed; } #region EventHandlers + private void MainWindow_Loaded(object sender, RoutedEventArgs e) + { + // Access command line arguments + string[] args = Environment.GetCommandLineArgs(); + + foreach (string arg in args) + { + if (arg.ToLower().Equals("start cs2")) + { + LaunchWeb("steam://rungameid/730"); + Button_LaunchCS.Content = "Launching CS2"; + _gameRunExtraDelay = 15; + } + + if (arg.ToLower().Equals("--minimize")) + { + WindowState = WindowState.Minimized; + } + } + } protected override void OnStateChanged(EventArgs e) { base.OnStateChanged(e); @@ -425,7 +432,7 @@ private void Program_state_Unchecked(object sender, RoutedEventArgs e) // PrintToLog("{Program_state_Unchecked}"); cts!.Cancel(); Program_state_continuously.IsChecked = false; - _scannerIsActive = false; + _scannerIsActive = false; // Change to a darker color Program_state.Foreground = new SolidColorBrush(Colors.Red); @@ -468,14 +475,15 @@ private void Program_state_continuously_Unchecked(object sender, RoutedEventArgs private void Run_at_startup_state_Checked(object sender, RoutedEventArgs e) { // PrintToLog("{Run_at_startup_state_Checked}"); - string exeLocation = $"{AppContext.BaseDirectory}CS2-AutoAccept"; + string exePath = GetExePath(); + try { RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); if (key.GetValue("CS2-AutoAccept") == null) { - key.SetValue("CS2-AutoAccept", exeLocation); + key.SetValue("CS2-AutoAccept", $"{exePath} --minimize"); } key.Close(); @@ -537,6 +545,15 @@ private void WindowSizeChangedEventHandler(object sender, SizeChangedEventArgs e File.WriteAllText(Path.Combine(_basePath, "settings.cs2_auto"), jsonString); } #endregion + private string GetExePath() + { + string? exeLocation5 = Process.GetCurrentProcess().MainModule?.FileName; + + string executingDir = AppDomain.CurrentDomain.BaseDirectory; + string executingName = Path.GetFileNameWithoutExtension(Environment.GetCommandLineArgs()[0]); + + return exeLocation5 ?? $"{Path.Combine(executingDir, executingName)}.exe"; + } /// /// Restore the window size, if it was previously opened & changed /// diff --git a/CS2-AutoAccept/Properties/launchSettings.json b/CS2-AutoAccept/Properties/launchSettings.json new file mode 100644 index 0000000..c9ae35d --- /dev/null +++ b/CS2-AutoAccept/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "CS2-AutoAccept": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.dll b/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.dll index 4db65fb..e1ccc73 100644 Binary files a/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.dll and b/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.dll differ diff --git a/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.exe b/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.exe index 3a69ce6..eaa4089 100644 Binary files a/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.exe and b/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.exe differ diff --git a/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.pdb b/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.pdb index 2d9857e..8ccfdf0 100644 Binary files a/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.pdb and b/CS2-AutoAccept/bin/Release/net6.0-windows10.0.17763.0/publish/win-x86/CS2-AutoAccept.pdb differ diff --git a/CS2-AutoAccept/updateInfo.json b/CS2-AutoAccept/updateInfo.json index 14ccc4f..7337295 100644 --- a/CS2-AutoAccept/updateInfo.json +++ b/CS2-AutoAccept/updateInfo.json @@ -1,8 +1,13 @@ { - "version": "5.1.5.0", - "type": "major", - "changelog": "Removed keybinds temporarily & added system tray icon as requested.", + "version": "5.1.5.1", + "type": "Bugfix", + "changelog": "Fixed a bug where the application would not start with windows.", "historic_versions": [ + { + "version": "5.1.5.0", + "type": "major", + "changelog": "Removed keybinds temporarily & added system tray icon as requested." + }, { "version": "5.1.4.5", "type": "minor",