From d8bf8ed4636befe8ea54877fe95a3ab10081c324 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Fri, 19 Jan 2024 20:39:50 +0100 Subject: [PATCH] Start/Stop for AC services on Ally --- app/Ally/AllyControl.cs | 25 ++++++++++++------ app/Helpers/OptimizationService.cs | 41 ++++++++++++++++++++++++++++++ app/Helpers/ProcessHelper.cs | 4 +-- app/Settings.cs | 2 +- 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/app/Ally/AllyControl.cs b/app/Ally/AllyControl.cs index c4aec4d4..c7457db5 100644 --- a/app/Ally/AllyControl.cs +++ b/app/Ally/AllyControl.cs @@ -66,12 +66,13 @@ namespace GHelper.Ally public const string BindKBU = "02-98"; public const string BindKBD = "02-99"; - public const string BindKBL = "02-91"; - public const string BindKBR = "02-9D"; + public const string BindKBL = "02-9A"; + public const string BindKBR = "02-9B"; public const string BindTab = "02-0D"; public const string BindEnter = "02-5A"; public const string BindBack = "02-66"; + public const string BindEsc = "02-76"; public const string BindPgU = "02-96"; public const string BindPgD = "02-97"; @@ -86,6 +87,7 @@ namespace GHelper.Ally public const string BindBrightnessUp = "04-04-8C-88-8A-06"; public const string BindOverlay = "04-03-8C-88-44"; + public const string BindShiftTab = "04-02-88-0D"; static byte[] CommandReady = new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0a, 0x01 }; @@ -122,7 +124,7 @@ namespace GHelper.Ally { "01-13", "XBox/Steam" }, - { "02-76", "Esc" }, + { BindEsc, "Esc" }, { "02-05", "F1" }, { "02-06", "F2" }, { "02-04", "F3" }, @@ -231,6 +233,7 @@ namespace GHelper.Ally { BindTaskManager, "Task Manager" }, { BindCloseWindow, "Close Window" }, + { BindShiftTab, "Shift-Tab" }, { "05-16", "Screenshot" }, { "05-19", "Show keyboard" }, @@ -292,14 +295,20 @@ namespace GHelper.Ally switch (fpsLimit) { case 30: - fpsLimit = 40; + fpsLimit = 45; break; - case 40: + case 45: fpsLimit = 60; break; case 60: + fpsLimit = 90; + break; + case 90: fpsLimit = 120; break; + case 120: + fpsLimit = 240; + break; default: fpsLimit = 30; break; @@ -393,7 +402,7 @@ namespace GHelper.Ally break; case BindingZone.AB: KeyL1 = AppConfig.GetString("bind_a", desktop ? BindEnter : BindA); - KeyR1 = AppConfig.GetString("bind_b", desktop ? BindBack : BindB); + KeyR1 = AppConfig.GetString("bind_b", desktop ? BindEsc : BindB); KeyL2 = AppConfig.GetString("bind2_a"); KeyR2 = AppConfig.GetString("bind2_b"); break; @@ -407,7 +416,7 @@ namespace GHelper.Ally KeyL1 = AppConfig.GetString("bind_vb", BindVB); KeyR1 = AppConfig.GetString("bind_mb", BindMB); KeyL2 = AppConfig.GetString("bind2_vb"); - KeyR2 = AppConfig.GetString("bind2_mb", BindCloseWindow); + KeyR2 = AppConfig.GetString("bind2_mb"); break; case BindingZone.M1M2: KeyL1 = AppConfig.GetString("bind_m2", BindM2); @@ -416,7 +425,7 @@ namespace GHelper.Ally KeyR2 = AppConfig.GetString("bind2_m1", BindM1); break; default: - KeyL1 = AppConfig.GetString("bind_trl", desktop ? BindCtrl : BindLT); + KeyL1 = AppConfig.GetString("bind_trl", desktop ? BindShiftTab : BindLT); KeyR1 = AppConfig.GetString("bind_trr", desktop ? BindMouseR : BindRT); KeyL2 = AppConfig.GetString("bind2_trl"); KeyR2 = AppConfig.GetString("bind2_trr"); diff --git a/app/Helpers/OptimizationService.cs b/app/Helpers/OptimizationService.cs index 18218b1e..d0a2f34d 100644 --- a/app/Helpers/OptimizationService.cs +++ b/app/Helpers/OptimizationService.cs @@ -18,6 +18,16 @@ namespace GHelper.Helpers "AsusCertService" }; + static List processesAC = new() { + "ArmouryCrateSE.Service", + "LightingService", + }; + + static List servicesAC = new() { + "ArmouryCrateSEService", + "LightingService", + }; + public static bool IsRunning() { return Process.GetProcessesByName("AsusOptimization").Count() > 0; @@ -36,6 +46,17 @@ namespace GHelper.Helpers { if (Process.GetProcessesByName(service).Count() > 0) count++; } + + if (AppConfig.IsAlly()) + foreach (string service in processesAC) + { + if (Process.GetProcessesByName(service).Count() > 0) + { + count++; + Logger.WriteLine(service); + } + } + return count; } @@ -46,6 +67,16 @@ namespace GHelper.Helpers { ProcessHelper.StopDisableService(service); } + + if (AppConfig.IsAlly()) + { + foreach (string service in servicesAC) + { + ProcessHelper.StopDisableService(service, "Manual"); + } + Thread.Sleep(1000); + } + } public static void StartAsusServices() @@ -54,6 +85,16 @@ namespace GHelper.Helpers { ProcessHelper.StartEnableService(service); } + + if (AppConfig.IsAlly()) + { + foreach (string service in servicesAC) + { + ProcessHelper.StartEnableService(service); + } + Thread.Sleep(1000); + } + } } diff --git a/app/Helpers/ProcessHelper.cs b/app/Helpers/ProcessHelper.cs index 2f5286e6..7c6303fb 100644 --- a/app/Helpers/ProcessHelper.cs +++ b/app/Helpers/ProcessHelper.cs @@ -94,11 +94,11 @@ namespace GHelper.Helpers } } - public static void StopDisableService(string serviceName) + public static void StopDisableService(string serviceName, string disable = "Disabled") { try { - string script = $"Get-Service -Name \"{serviceName}\" | Stop-Service -Force -PassThru | Set-Service -StartupType Disabled"; + string script = $"Get-Service -Name \"{serviceName}\" | Stop-Service -Force -PassThru | Set-Service -StartupType {disable}"; Logger.WriteLine(script); RunCMD("powershell", script); } diff --git a/app/Settings.cs b/app/Settings.cs index 54cc81df..c5645950 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -321,7 +321,7 @@ namespace GHelper public void VisualiseFPSLimit(int limit) { - buttonFPS.Text = "FPS Limit " + ((limit > 0 && limit < 120) ? limit : "OFF"); + buttonFPS.Text = "FPS Limit " + ((limit > 0 && limit <= 120) ? limit : "OFF"); } private void SettingsForm_LostFocus(object? sender, EventArgs e)