Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-edit clear temp file, fixed get current volume
Greedeks3b53eaab9e38
diff --git a/.Source/GTweak/Utilities/Settings.cs b/.Source/GTweak/Utilities/Settings.csindex 46020c0b..df7d50b2 100644--- a/.Source/GTweak/Utilities/Settings.cs+++ b/.Source/GTweak/Utilities/Settings.cs@@ -32,7 +32,6 @@ namespace GTweak.Utilitiespublic static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);}- private const uint volumeFirstStart = 50;private static bool _isViewNotification = true;private static bool _isPlayingSound = true;private static bool _isTopMost = false;@@ -41,6 +40,8 @@ namespace GTweak.Utilitiesprivate static string _theme = "Dark";internal static bool _isHiddenIpAddress = false;+ private const uint defaultVolume = 50;+ internal static uint currentVolume = 0;internal static int PID = 0;internal static string currentRelease = (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.Split(' ').Last().Trim();internal static readonly string currentName = AppDomain.CurrentDomain.FriendlyName;@@ -67,7 +68,7 @@ namespace GTweak.UtilitiesregistryKey?.SetValue("HiddenIP", IsHiddenIpAddress, RegistryValueKind.String);registryKey?.SetValue("Theme", Theme, RegistryValueKind.String);registryKey?.SetValue("Language", App.GettingSystemLanguage, RegistryValueKind.String);- WinmmMethods.waveOutSetVolume(IntPtr.Zero, ((uint)(double)((ushort.MaxValue / 100) * volumeFirstStart) & 0x0000ffff) | ((uint)(double)((ushort.MaxValue / 100) * volumeFirstStart) << 16));+ WinmmMethods.waveOutSetVolume(IntPtr.Zero, ((uint)(double)((ushort.MaxValue / 100) * defaultVolume) & 0x0000ffff) | ((uint)(double)((ushort.MaxValue / 100) * defaultVolume) << 16));}else{@@ -78,6 +79,7 @@ namespace GTweak.UtilitiesIsHiddenIpAddress = bool.Parse(registryKey?.GetValue("HiddenIP").ToString() ?? "False");Language = registryKey?.GetValue("Language").ToString() ?? App.GettingSystemLanguage;Theme = registryKey?.GetValue("Theme").ToString() ?? "Dark";+ WinmmMethods.waveOutGetVolume(IntPtr.Zero, out currentVolume);}registryKey?.Close();diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex 0f24b62c..6bb78103 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -382,32 +382,29 @@ namespace GTweak.Utilities.TweaksRegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\WindowsStore", "AutoDownload");break;case "TglButton7":- byte[] _dataTime;- byte[] _dataState;+ byte[] dataTime, dataState;if (isChoose){- _dataTime = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF };- _dataState = Encoding.Unicode.GetBytes("\0\0");+ dataTime = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF };+ dataState = Encoding.Unicode.GetBytes("\0\0");}else{- _dataTime = new byte[] { 0x0a, 0x00, 0x00, 0x00 };- _dataState = new byte[] { 0x03, 0x00, 0x00, 0x00 };+ dataTime = new byte[] { 0x0a, 0x00, 0x00, 0x00 };+ dataState = new byte[] { 0x03, 0x00, 0x00, 0x00 };}try{RegistryKey registrykey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}", true);-- foreach (string Keyname in registrykey.GetSubKeyNames())+ foreach (string KeyName in registrykey.GetSubKeyNames()){- RegistryKey keyView = registrykey?.OpenSubKey(Keyname);+ RegistryKey keyView = registrykey?.OpenSubKey(KeyName);if (keyView?.GetValue("DriverDesc")?.ToString() == "Realtek High Definition Audio"){- RegistryKey keychange = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}\" + Keyname + @"\PowerSettings", true);- keychange?.SetValue("ConservationIdleTime", _dataTime, RegistryValueKind.Binary);- keychange?.SetValue("IdlePowerState", _dataState, RegistryValueKind.Binary);- keychange?.SetValue("PerformanceIdleTime", _dataTime, RegistryValueKind.Binary);+ RegistryHelp.Write(Registry.LocalMachine, $@"SYSTEM\CurrentControlSet\Control\Class\{{4d36e96c-e325-11ce-bfc1-08002be10318}}\{KeyName}\PowerSettings", "ConservationIdleTime", dataTime, RegistryValueKind.Binary);+ RegistryHelp.Write(Registry.LocalMachine, $@"SYSTEM\CurrentControlSet\Control\Class\{{4d36e96c-e325-11ce-bfc1-08002be10318}}\{KeyName}\PowerSettings", "IdlePowerState", dataState, RegistryValueKind.Binary);+ RegistryHelp.Write(Registry.LocalMachine, $@"SYSTEM\CurrentControlSet\Control\Class\{{4d36e96c-e325-11ce-bfc1-08002be10318}}\{KeyName}\PowerSettings", "PerformanceIdleTime", dataTime, RegistryValueKind.Binary);}}}@@ -696,7 +693,7 @@ namespace GTweak.Utilities.TweaksProcess.Start(new ProcessStartInfo(){- Arguments = $"/c timeout /t 10 && del {pathTempFile}",+ Arguments = $"/c timeout /t 10 && rd /s /q {UsePath.FileLocation}",WindowStyle = ProcessWindowStyle.Hidden,CreateNoWindow = true,FileName = "cmd.exe"@@ -705,19 +702,17 @@ namespace GTweak.Utilities.Tweaks}else{- string _activePowerScheme = @"Microsoft:PowerPlan\\{" + Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes").GetValue("ActivePowerScheme").ToString() + "}";+ string activeScheme = @"Microsoft:PowerPlan\\{" + Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes").GetValue("ActivePowerScheme").ToString() + "}";Parallel.Invoke(() =>{- foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2\power", "SELECT InstanceID FROM Win32_PowerPlan WHERE InstanceID !='" + _activePowerScheme + "'").Get())+ foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2\power", "SELECT InstanceID FROM Win32_PowerPlan WHERE InstanceID !='" + activeScheme + "'").Get())serchScheme = Convert.ToString(managementObj["InstanceID"]);});- serchScheme = Regex.Match(serchScheme, @"\{([^)]*)\}").Groups[1].Value;-using (_powercfg){- _powercfg.StartInfo.Arguments = $"/setactive {serchScheme}";+ _powercfg.StartInfo.Arguments = $"/setactive {Regex.Match(serchScheme, @"\{([^)]*)\}").Groups[1].Value}";_powercfg.Start();}}diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.csindex 3e2c4677..6caa4e61 100644--- a/.Source/GTweak/Windows/MainWindow.xaml.cs+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs@@ -23,8 +23,7 @@ namespace GTweakBtnUpdate.StateNA = Settings.IsСheckingUpdate;BtnTopMost.StateNA = Topmost = Settings.IsTopMost;BtnSoundNtn.IsChecked = Settings.IsPlayingSound;- Settings.WinmmMethods.waveOutGetVolume(IntPtr.Zero, out uint CurrentVolume);- SliderVolume.Value = (ushort)(CurrentVolume & 0x0000ffff) / (ushort.MaxValue / 100);+ SliderVolume.Value = (ushort)(Settings.currentVolume & 0x0000ffff) / (ushort.MaxValue / 100);LanguageSelectionMenu.SelectedIndex = Settings.Language == "en" ? 0 : 1;ThemeSelectionMenu.SelectedIndex = Settings.Theme switch{