Compare commits

..

12 Commits
v0.7 ... v0.8.3

Author SHA1 Message Date
seerge
4bbd5da4af Another attempt to fix icon sizing 2023-02-19 00:04:30 +01:00
seerge
023d7388bd Added CPU boost control 2023-02-18 21:08:22 +01:00
seerge
e782467585 Merge branch 'master' of https://github.com/seerge/GHelper 2023-02-18 15:33:00 +01:00
seerge
870ca664c8 Max refresh rate fix 2023-02-18 15:32:13 +01:00
seerge
dd4e89cc97 Max refresh rate fix 2023-02-18 15:31:37 +01:00
seerge
d20aaf9410 Merge branch 'main' of https://github.com/seerge/g14-helper 2023-02-18 14:42:31 +01:00
seerge
811ea03ad5 New screenshot 2023-02-18 14:39:47 +01:00
seerge
414167f008 Fixed resolution switching when laptop screen is not main, added support for > 120hz laptop screens 2023-02-18 14:38:20 +01:00
seerge
7683f2472b Merge branch 'master' of https://github.com/seerge/GHelper 2023-02-18 00:25:47 +01:00
seerge
6fdffecfb9 Update README.md 2023-02-18 00:09:20 +01:00
seerge
f1af8b87b3 Merge branch 'main' of https://github.com/seerge/g14-helper 2023-02-17 23:49:37 +01:00
seerge
13b02b6c2e Added screen refresh and display overdrive changes, and fixed crash on 2021 model 2023-02-17 23:43:12 +01:00
7 changed files with 396 additions and 134 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows8.0</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>True</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
@@ -10,7 +10,6 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject>GHelper.Program</StartupObject>
<ApplicationIcon>Resources\standard.ico</ApplicationIcon>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
@@ -31,7 +30,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.1" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
</ItemGroup>

View File

@@ -1,11 +1,10 @@
using Microsoft.Win32.TaskScheduler;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Diagnostics;
using System.Management;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text.Json;
public class ASUSWmi
{
private ManagementObject mo;
@@ -59,7 +58,8 @@ public class ASUSWmi
status = int.Parse(property.Value.ToString());
status -= 65536;
return status;
} catch
}
catch
{
return -1;
}
@@ -69,7 +69,8 @@ public class ASUSWmi
try
{
return int.Parse(property.Value.ToString());
} catch
}
catch
{
return -1;
}
@@ -170,9 +171,14 @@ public class AppConfig
if (File.Exists(configFile))
{
string text = File.ReadAllText(configFile);
config = JsonConvert.DeserializeObject<Dictionary<string, object>>(text);
if (config is null)
try
{
config = JsonSerializer.Deserialize<Dictionary<string, object>>(text);
}
catch
{
initConfig();
}
}
else
{
@@ -185,13 +191,13 @@ public class AppConfig
{
config = new Dictionary<string, object>();
config["performance_mode"] = 0;
string jsonString = JsonConvert.SerializeObject(config);
string jsonString = JsonSerializer.Serialize(config);
File.WriteAllText(configFile, jsonString);
}
public int getConfig(string name)
{
if (config.ContainsKey(name))
if (config.ContainsKey(name))
return int.Parse(config[name].ToString());
else return -1;
}
@@ -199,7 +205,7 @@ public class AppConfig
public void setConfig(string name, int value)
{
config[name] = value;
string jsonString = JsonConvert.SerializeObject(config);
string jsonString = JsonSerializer.Serialize(config);
File.WriteAllText(configFile, jsonString);
}
@@ -208,9 +214,92 @@ public class AppConfig
}
public class PowerPlan
{
static void RunCommands(List<string> cmds, string workingDirectory = "")
{
var process = new Process();
var psi = new ProcessStartInfo();
psi.FileName = "powershell";
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.WorkingDirectory = workingDirectory;
process.StartInfo = psi;
process.Start();
process.OutputDataReceived += (sender, e) => { Debug.WriteLine(e.Data); };
process.ErrorDataReceived += (sender, e) => { Debug.WriteLine(e.Data); };
process.BeginOutputReadLine();
process.BeginErrorReadLine();
using (StreamWriter sw = process.StandardInput)
{
foreach (var cmd in cmds)
{
sw.WriteLine(cmd);
}
}
process.WaitForExit();
}
public static int getBoostStatus()
{
List<string> cmds = new List<string>
{
"$asGuid = [regex]::Match((powercfg /getactivescheme),'(\\{){0,1}[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}(\\}){0,1}').Value",
"$statusFull = (powercfg /QUERY $asGuid 54533251-82be-4824-96c1-47b60b740d00 be337238-0d82-4146-a960-4f3749d470c7) -match 'Current AC Power Setting Index'",
"[regex]::Match($statusFull,'(0x.{8})').Value"
};
RunCommands(cmds);
return 0;
}
}
public class NativeMethods
{
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
static extern UInt32 PowerWriteDCValueIndex(IntPtr RootPowerKey,
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
int AcValueIndex);
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
static extern UInt32 PowerReadACValueIndex(IntPtr RootPowerKey,
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
out IntPtr AcValueIndex
);
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
static extern UInt32 PowerWriteACValueIndex(IntPtr RootPowerKey,
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
int AcValueIndex);
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey,
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid);
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
static extern UInt32 PowerGetActiveScheme(IntPtr UserPowerKey, out IntPtr ActivePolicyGuid);
static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00");
static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7");
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct DEVMODE
{
@@ -251,21 +340,35 @@ public class NativeMethods
public int dmPanningHeight;
};
[Flags()]
public enum DisplaySettingsFlags : int
{
CDS_UPDATEREGISTRY = 1,
CDS_TEST = 2,
CDS_FULLSCREEN = 4,
CDS_GLOBAL = 8,
CDS_SET_PRIMARY = 0x10,
CDS_RESET = 0x40000000,
CDS_NORESET = 0x10000000
}
// PInvoke declaration for EnumDisplaySettings Win32 API
[DllImport("user32.dll")]
public static extern int EnumDisplaySettingsExA(
public static extern int EnumDisplaySettingsEx(
string lpszDeviceName,
int iModeNum,
ref DEVMODE lpDevMode);
// PInvoke declaration for ChangeDisplaySettings Win32 API
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(
ref DEVMODE lpDevMode,
int dwFlags);
public static extern int ChangeDisplaySettingsEx(
string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
DisplaySettingsFlags dwflags, IntPtr lParam);
public const int ENUM_CURRENT_SETTINGS = -1;
public const string laptopScreenName = "\\\\.\\DISPLAY1";
public static DEVMODE CreateDevmode()
{
@@ -276,34 +379,100 @@ public class NativeMethods
return dm;
}
public static Screen FindLaptopScreen()
{
var screens = Screen.AllScreens;
Screen laptopScreen = null;
foreach (var screen in screens)
{
if (screen.DeviceName == laptopScreenName)
{
laptopScreen = screen;
}
}
if (laptopScreen is null) return null;
else return laptopScreen;
}
public static int GetRefreshRate()
{
DEVMODE dm = CreateDevmode();
Screen laptopScreen = FindLaptopScreen();
int frequency = -1;
if (0 != NativeMethods.EnumDisplaySettingsExA(null, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
if (laptopScreen is null)
return -1;
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen.DeviceName, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
{
Debug.WriteLine(JsonConvert.SerializeObject(dm));
frequency = dm.dmDisplayFrequency;
}
return frequency;
}
public static void SetRefreshRate(int frequency = 120)
public static int SetRefreshRate(int frequency = 120)
{
DEVMODE dm = CreateDevmode();
Screen laptopScreen = FindLaptopScreen();
if (0 != NativeMethods.EnumDisplaySettingsExA(null,NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
if (laptopScreen is null)
return -1;
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen.DeviceName, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
{
dm.dmDisplayFrequency = frequency;
int iRet = NativeMethods.ChangeDisplaySettings(ref dm, 0);
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen.DeviceName, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
return iRet;
}
return 0;
}
static Guid GetActiveScheme()
{
IntPtr pActiveSchemeGuid;
var hr = PowerGetActiveScheme(IntPtr.Zero, out pActiveSchemeGuid);
Guid activeSchemeGuid = (Guid)Marshal.PtrToStructure(pActiveSchemeGuid, typeof(Guid));
return activeSchemeGuid;
}
public static int GetCPUBoost()
{
IntPtr AcValueIndex;
Guid activeSchemeGuid = GetActiveScheme();
UInt32 value = PowerReadACValueIndex(IntPtr.Zero,
activeSchemeGuid,
GUID_CPU,
GUID_BOOST, out AcValueIndex);
return AcValueIndex.ToInt32();
}
public static void SetCPUBoost(int boost = 0)
{
Guid activeSchemeGuid = GetActiveScheme();
var hr = PowerWriteACValueIndex(
IntPtr.Zero,
activeSchemeGuid,
GUID_CPU,
GUID_BOOST,
boost);
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
}
}
namespace GHelper
{
static class Program
@@ -338,6 +507,7 @@ namespace GHelper
settingsForm = new SettingsForm();
settingsForm.InitGPUMode();
settingsForm.InitBoost();
settingsForm.SetPerformanceMode(config.getConfig("performance_mode"));
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));

View File

@@ -26,7 +26,8 @@ Profiles are **same** as in Armory Crate, including default fan curves
2. CPU and GPU relative fan speed monitoring
3. Automatic switching of Standard/Eco GPU modes when laptop is plugged / unplugged!
4. FN+F5 an M4 (Rog) keys cycle through Performance modes
5. Start with windows (optional)
5. Screen resolution and display overdrive switching
6. Run on startup (optional)
## How to install
@@ -41,7 +42,7 @@ I don`t have Microsoft certificate to sign app yet, so if you set a warning from
Alternatively you can comile and run project by yourself :)
Settings are located in APPDATA\ROAMING
Settings file is storer at %AppData%\GHelper
P.S.: It's not recommended to use app in combination with Armory Crate, cause they adjust same settings.
Please keep in mind, that if you also run MyASUS app periodically it will also try to adjust same battery charge settings

193
Settings.Designer.cs generated
View File

@@ -55,6 +55,7 @@
this.button120Hz = new System.Windows.Forms.Button();
this.button60Hz = new System.Windows.Forms.Button();
this.checkScreen = new System.Windows.Forms.CheckBox();
this.checkBoost = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.trackBattery)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBattery)).BeginInit();
this.tableGPU.SuspendLayout();
@@ -69,9 +70,10 @@
//
this.checkStartup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.checkStartup.AutoSize = true;
this.checkStartup.Location = new System.Drawing.Point(34, 836);
this.checkStartup.Location = new System.Drawing.Point(18, 409);
this.checkStartup.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkStartup.Name = "checkStartup";
this.checkStartup.Size = new System.Drawing.Size(206, 36);
this.checkStartup.Size = new System.Drawing.Size(105, 19);
this.checkStartup.TabIndex = 2;
this.checkStartup.Text = "Run on Startup";
this.checkStartup.UseVisualStyleBackColor = true;
@@ -82,11 +84,12 @@
this.trackBattery.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.trackBattery.LargeChange = 20;
this.trackBattery.Location = new System.Drawing.Point(23, 744);
this.trackBattery.Location = new System.Drawing.Point(12, 359);
this.trackBattery.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.trackBattery.Maximum = 100;
this.trackBattery.Minimum = 50;
this.trackBattery.Name = "trackBattery";
this.trackBattery.Size = new System.Drawing.Size(651, 90);
this.trackBattery.Size = new System.Drawing.Size(361, 45);
this.trackBattery.SmallChange = 10;
this.trackBattery.TabIndex = 3;
this.trackBattery.TickFrequency = 10;
@@ -97,9 +100,10 @@
//
this.labelBattery.AutoSize = true;
this.labelBattery.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelBattery.Location = new System.Drawing.Point(83, 701);
this.labelBattery.Location = new System.Drawing.Point(45, 339);
this.labelBattery.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelBattery.Name = "labelBattery";
this.labelBattery.Size = new System.Drawing.Size(248, 32);
this.labelBattery.Size = new System.Drawing.Size(122, 15);
this.labelBattery.TabIndex = 4;
this.labelBattery.Text = "Battery Charge Limit";
//
@@ -107,18 +111,21 @@
//
this.labelBatteryLimit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelBatteryLimit.AutoSize = true;
this.labelBatteryLimit.Location = new System.Drawing.Point(596, 699);
this.labelBatteryLimit.Location = new System.Drawing.Point(331, 338);
this.labelBatteryLimit.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelBatteryLimit.Name = "labelBatteryLimit";
this.labelBatteryLimit.Size = new System.Drawing.Size(73, 32);
this.labelBatteryLimit.Size = new System.Drawing.Size(35, 15);
this.labelBatteryLimit.TabIndex = 5;
this.labelBatteryLimit.Text = "100%";
//
// pictureBattery
//
this.pictureBattery.Image = global::GHelper.Properties.Resources.icons8_charging_battery_48;
this.pictureBattery.Location = new System.Drawing.Point(32, 693);
this.pictureBattery.BackgroundImage = global::GHelper.Properties.Resources.icons8_charging_battery_48;
this.pictureBattery.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.pictureBattery.Location = new System.Drawing.Point(17, 335);
this.pictureBattery.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.pictureBattery.Name = "pictureBattery";
this.pictureBattery.Size = new System.Drawing.Size(48, 48);
this.pictureBattery.Size = new System.Drawing.Size(26, 22);
this.pictureBattery.TabIndex = 6;
this.pictureBattery.TabStop = false;
//
@@ -126,9 +133,10 @@
//
this.labelGPUFan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelGPUFan.AutoSize = true;
this.labelGPUFan.Location = new System.Drawing.Point(515, 234);
this.labelGPUFan.Location = new System.Drawing.Point(293, 123);
this.labelGPUFan.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelGPUFan.Name = "labelGPUFan";
this.labelGPUFan.Size = new System.Drawing.Size(155, 32);
this.labelGPUFan.Size = new System.Drawing.Size(77, 15);
this.labelGPUFan.TabIndex = 8;
this.labelGPUFan.Text = "GPU Fan : 0%";
//
@@ -143,11 +151,12 @@
this.tableGPU.Controls.Add(this.buttonUltimate, 2, 0);
this.tableGPU.Controls.Add(this.buttonStandard, 1, 0);
this.tableGPU.Controls.Add(this.buttonEco, 0, 0);
this.tableGPU.Location = new System.Drawing.Point(23, 276);
this.tableGPU.Location = new System.Drawing.Point(12, 142);
this.tableGPU.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.tableGPU.Name = "tableGPU";
this.tableGPU.RowCount = 1;
this.tableGPU.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F));
this.tableGPU.Size = new System.Drawing.Size(651, 106);
this.tableGPU.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableGPU.Size = new System.Drawing.Size(361, 50);
this.tableGPU.TabIndex = 7;
//
// buttonUltimate
@@ -156,10 +165,10 @@
this.buttonUltimate.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonUltimate.FlatAppearance.BorderSize = 0;
this.buttonUltimate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonUltimate.Location = new System.Drawing.Point(444, 10);
this.buttonUltimate.Margin = new System.Windows.Forms.Padding(10);
this.buttonUltimate.Location = new System.Drawing.Point(245, 5);
this.buttonUltimate.Margin = new System.Windows.Forms.Padding(5);
this.buttonUltimate.Name = "buttonUltimate";
this.buttonUltimate.Size = new System.Drawing.Size(197, 86);
this.buttonUltimate.Size = new System.Drawing.Size(111, 40);
this.buttonUltimate.TabIndex = 2;
this.buttonUltimate.Text = "Ultimate";
this.buttonUltimate.UseVisualStyleBackColor = false;
@@ -170,10 +179,10 @@
this.buttonStandard.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonStandard.FlatAppearance.BorderSize = 0;
this.buttonStandard.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonStandard.Location = new System.Drawing.Point(227, 10);
this.buttonStandard.Margin = new System.Windows.Forms.Padding(10);
this.buttonStandard.Location = new System.Drawing.Point(125, 5);
this.buttonStandard.Margin = new System.Windows.Forms.Padding(5);
this.buttonStandard.Name = "buttonStandard";
this.buttonStandard.Size = new System.Drawing.Size(197, 86);
this.buttonStandard.Size = new System.Drawing.Size(110, 40);
this.buttonStandard.TabIndex = 1;
this.buttonStandard.Text = "Standard";
this.buttonStandard.UseVisualStyleBackColor = false;
@@ -185,10 +194,10 @@
this.buttonEco.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonEco.FlatAppearance.BorderSize = 0;
this.buttonEco.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonEco.Location = new System.Drawing.Point(10, 10);
this.buttonEco.Margin = new System.Windows.Forms.Padding(10);
this.buttonEco.Location = new System.Drawing.Point(5, 5);
this.buttonEco.Margin = new System.Windows.Forms.Padding(5);
this.buttonEco.Name = "buttonEco";
this.buttonEco.Size = new System.Drawing.Size(197, 86);
this.buttonEco.Size = new System.Drawing.Size(110, 40);
this.buttonEco.TabIndex = 0;
this.buttonEco.Text = "Eco";
this.buttonEco.UseVisualStyleBackColor = false;
@@ -197,18 +206,21 @@
//
this.labelGPU.AutoSize = true;
this.labelGPU.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelGPU.Location = new System.Drawing.Point(82, 234);
this.labelGPU.Location = new System.Drawing.Point(45, 124);
this.labelGPU.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelGPU.Name = "labelGPU";
this.labelGPU.Size = new System.Drawing.Size(136, 32);
this.labelGPU.Size = new System.Drawing.Size(67, 15);
this.labelGPU.TabIndex = 9;
this.labelGPU.Text = "GPU Mode";
//
// pictureGPU
//
this.pictureGPU.Image = global::GHelper.Properties.Resources.icons8_video_card_48;
this.pictureGPU.Location = new System.Drawing.Point(32, 226);
this.pictureGPU.BackgroundImage = global::GHelper.Properties.Resources.icons8_video_card_48;
this.pictureGPU.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.pictureGPU.Location = new System.Drawing.Point(17, 120);
this.pictureGPU.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.pictureGPU.Name = "pictureGPU";
this.pictureGPU.Size = new System.Drawing.Size(48, 48);
this.pictureGPU.Size = new System.Drawing.Size(26, 22);
this.pictureGPU.TabIndex = 10;
this.pictureGPU.TabStop = false;
//
@@ -216,9 +228,10 @@
//
this.labelCPUFan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelCPUFan.AutoSize = true;
this.labelCPUFan.Location = new System.Drawing.Point(517, 39);
this.labelCPUFan.Location = new System.Drawing.Point(293, 18);
this.labelCPUFan.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelCPUFan.Name = "labelCPUFan";
this.labelCPUFan.Size = new System.Drawing.Size(154, 32);
this.labelCPUFan.Size = new System.Drawing.Size(77, 15);
this.labelCPUFan.TabIndex = 12;
this.labelCPUFan.Text = "CPU Fan : 0%";
//
@@ -233,11 +246,12 @@
this.tablePerf.Controls.Add(this.buttonTurbo, 2, 0);
this.tablePerf.Controls.Add(this.buttonBalanced, 1, 0);
this.tablePerf.Controls.Add(this.buttonSilent, 0, 0);
this.tablePerf.Location = new System.Drawing.Point(23, 79);
this.tablePerf.Location = new System.Drawing.Point(12, 37);
this.tablePerf.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.tablePerf.Name = "tablePerf";
this.tablePerf.RowCount = 1;
this.tablePerf.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F));
this.tablePerf.Size = new System.Drawing.Size(651, 106);
this.tablePerf.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tablePerf.Size = new System.Drawing.Size(361, 50);
this.tablePerf.TabIndex = 11;
//
// buttonTurbo
@@ -247,10 +261,10 @@
this.buttonTurbo.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.buttonTurbo.FlatAppearance.BorderSize = 0;
this.buttonTurbo.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonTurbo.Location = new System.Drawing.Point(444, 10);
this.buttonTurbo.Margin = new System.Windows.Forms.Padding(10);
this.buttonTurbo.Location = new System.Drawing.Point(245, 5);
this.buttonTurbo.Margin = new System.Windows.Forms.Padding(5);
this.buttonTurbo.Name = "buttonTurbo";
this.buttonTurbo.Size = new System.Drawing.Size(197, 86);
this.buttonTurbo.Size = new System.Drawing.Size(111, 40);
this.buttonTurbo.TabIndex = 2;
this.buttonTurbo.Text = "Turbo";
this.buttonTurbo.UseVisualStyleBackColor = false;
@@ -262,10 +276,10 @@
this.buttonBalanced.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.buttonBalanced.FlatAppearance.BorderSize = 0;
this.buttonBalanced.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonBalanced.Location = new System.Drawing.Point(227, 10);
this.buttonBalanced.Margin = new System.Windows.Forms.Padding(10);
this.buttonBalanced.Location = new System.Drawing.Point(125, 5);
this.buttonBalanced.Margin = new System.Windows.Forms.Padding(5);
this.buttonBalanced.Name = "buttonBalanced";
this.buttonBalanced.Size = new System.Drawing.Size(197, 86);
this.buttonBalanced.Size = new System.Drawing.Size(110, 40);
this.buttonBalanced.TabIndex = 1;
this.buttonBalanced.Text = "Balanced";
this.buttonBalanced.UseVisualStyleBackColor = false;
@@ -278,20 +292,23 @@
this.buttonSilent.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.buttonSilent.FlatAppearance.BorderSize = 0;
this.buttonSilent.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonSilent.Location = new System.Drawing.Point(10, 10);
this.buttonSilent.Margin = new System.Windows.Forms.Padding(10);
this.buttonSilent.Location = new System.Drawing.Point(5, 5);
this.buttonSilent.Margin = new System.Windows.Forms.Padding(5);
this.buttonSilent.Name = "buttonSilent";
this.buttonSilent.Size = new System.Drawing.Size(197, 86);
this.buttonSilent.Size = new System.Drawing.Size(110, 40);
this.buttonSilent.TabIndex = 0;
this.buttonSilent.Text = "Silent";
this.buttonSilent.UseVisualStyleBackColor = false;
//
// picturePerf
//
this.picturePerf.Image = global::GHelper.Properties.Resources.icons8_speed_48;
this.picturePerf.Location = new System.Drawing.Point(32, 29);
this.picturePerf.BackgroundImage = global::GHelper.Properties.Resources.icons8_speed_48;
this.picturePerf.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.picturePerf.InitialImage = null;
this.picturePerf.Location = new System.Drawing.Point(17, 15);
this.picturePerf.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.picturePerf.Name = "picturePerf";
this.picturePerf.Size = new System.Drawing.Size(48, 48);
this.picturePerf.Size = new System.Drawing.Size(26, 22);
this.picturePerf.TabIndex = 14;
this.picturePerf.TabStop = false;
//
@@ -299,20 +316,23 @@
//
this.labelPerf.AutoSize = true;
this.labelPerf.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelPerf.Location = new System.Drawing.Point(83, 37);
this.labelPerf.Location = new System.Drawing.Point(45, 19);
this.labelPerf.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelPerf.Name = "labelPerf";
this.labelPerf.Size = new System.Drawing.Size(234, 32);
this.labelPerf.Size = new System.Drawing.Size(115, 15);
this.labelPerf.TabIndex = 13;
this.labelPerf.Text = "Performance Mode";
//
// checkGPU
//
this.checkGPU.AutoSize = true;
this.checkGPU.Location = new System.Drawing.Point(34, 385);
this.checkGPU.ForeColor = System.Drawing.SystemColors.GrayText;
this.checkGPU.Location = new System.Drawing.Point(18, 192);
this.checkGPU.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkGPU.Name = "checkGPU";
this.checkGPU.Size = new System.Drawing.Size(614, 36);
this.checkGPU.Size = new System.Drawing.Size(273, 19);
this.checkGPU.TabIndex = 15;
this.checkGPU.Text = "Switch to Eco on battery and Standard when plugged";
this.checkGPU.Text = "Set Eco on battery and Standard when plugged";
this.checkGPU.UseVisualStyleBackColor = true;
this.checkGPU.CheckedChanged += new System.EventHandler(this.checkGPU_CheckedChanged);
//
@@ -320,19 +340,22 @@
//
this.buttonQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonQuit.BackColor = System.Drawing.SystemColors.ButtonFace;
this.buttonQuit.Location = new System.Drawing.Point(551, 830);
this.buttonQuit.Location = new System.Drawing.Point(307, 409);
this.buttonQuit.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.buttonQuit.Name = "buttonQuit";
this.buttonQuit.Size = new System.Drawing.Size(120, 46);
this.buttonQuit.Size = new System.Drawing.Size(65, 22);
this.buttonQuit.TabIndex = 16;
this.buttonQuit.Text = "Quit";
this.buttonQuit.UseVisualStyleBackColor = false;
//
// pictureScreen
//
this.pictureScreen.Image = global::GHelper.Properties.Resources.icons8_laptop_48;
this.pictureScreen.Location = new System.Drawing.Point(32, 463);
this.pictureScreen.BackgroundImage = global::GHelper.Properties.Resources.icons8_laptop_48;
this.pictureScreen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.pictureScreen.Location = new System.Drawing.Point(17, 229);
this.pictureScreen.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.pictureScreen.Name = "pictureScreen";
this.pictureScreen.Size = new System.Drawing.Size(48, 48);
this.pictureScreen.Size = new System.Drawing.Size(26, 22);
this.pictureScreen.TabIndex = 18;
this.pictureScreen.TabStop = false;
//
@@ -340,9 +363,10 @@
//
this.labelSreen.AutoSize = true;
this.labelSreen.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelSreen.Location = new System.Drawing.Point(82, 471);
this.labelSreen.Location = new System.Drawing.Point(45, 233);
this.labelSreen.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelSreen.Name = "labelSreen";
this.labelSreen.Size = new System.Drawing.Size(176, 32);
this.labelSreen.Size = new System.Drawing.Size(87, 15);
this.labelSreen.TabIndex = 17;
this.labelSreen.Text = "Laptop Screen";
//
@@ -356,23 +380,25 @@
this.tableScreen.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableScreen.Controls.Add(this.button120Hz, 1, 0);
this.tableScreen.Controls.Add(this.button60Hz, 0, 0);
this.tableScreen.Location = new System.Drawing.Point(23, 513);
this.tableScreen.Location = new System.Drawing.Point(12, 251);
this.tableScreen.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.tableScreen.Name = "tableScreen";
this.tableScreen.RowCount = 1;
this.tableScreen.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F));
this.tableScreen.Size = new System.Drawing.Size(651, 103);
this.tableScreen.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableScreen.Size = new System.Drawing.Size(361, 48);
this.tableScreen.TabIndex = 19;
//
// button120Hz
//
this.button120Hz.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.button120Hz.Dock = System.Windows.Forms.DockStyle.Fill;
this.button120Hz.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveBorder;
this.button120Hz.FlatAppearance.BorderSize = 0;
this.button120Hz.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button120Hz.Location = new System.Drawing.Point(227, 10);
this.button120Hz.Margin = new System.Windows.Forms.Padding(10);
this.button120Hz.Location = new System.Drawing.Point(125, 5);
this.button120Hz.Margin = new System.Windows.Forms.Padding(5);
this.button120Hz.Name = "button120Hz";
this.button120Hz.Size = new System.Drawing.Size(197, 86);
this.button120Hz.Size = new System.Drawing.Size(110, 40);
this.button120Hz.TabIndex = 1;
this.button120Hz.Text = "120Hz + OD";
this.button120Hz.UseVisualStyleBackColor = false;
@@ -382,12 +408,14 @@
this.button60Hz.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.button60Hz.CausesValidation = false;
this.button60Hz.Dock = System.Windows.Forms.DockStyle.Fill;
this.button60Hz.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveBorder;
this.button60Hz.FlatAppearance.BorderSize = 0;
this.button60Hz.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button60Hz.Location = new System.Drawing.Point(10, 10);
this.button60Hz.Margin = new System.Windows.Forms.Padding(10);
this.button60Hz.ForeColor = System.Drawing.SystemColors.ControlText;
this.button60Hz.Location = new System.Drawing.Point(5, 5);
this.button60Hz.Margin = new System.Windows.Forms.Padding(5);
this.button60Hz.Name = "button60Hz";
this.button60Hz.Size = new System.Drawing.Size(197, 86);
this.button60Hz.Size = new System.Drawing.Size(110, 40);
this.button60Hz.TabIndex = 0;
this.button60Hz.Text = "60Hz";
this.button60Hz.UseVisualStyleBackColor = false;
@@ -395,18 +423,33 @@
// checkScreen
//
this.checkScreen.AutoSize = true;
this.checkScreen.Location = new System.Drawing.Point(34, 622);
this.checkScreen.ForeColor = System.Drawing.SystemColors.GrayText;
this.checkScreen.Location = new System.Drawing.Point(18, 299);
this.checkScreen.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkScreen.Name = "checkScreen";
this.checkScreen.Size = new System.Drawing.Size(562, 36);
this.checkScreen.Size = new System.Drawing.Size(261, 19);
this.checkScreen.TabIndex = 20;
this.checkScreen.Text = "Switch 60Hz on battery, and back when plugged";
this.checkScreen.Text = "Set 60Hz on battery, and back when plugged";
this.checkScreen.UseVisualStyleBackColor = true;
//
// checkBoost
//
this.checkBoost.AutoSize = true;
this.checkBoost.ForeColor = System.Drawing.SystemColors.GrayText;
this.checkBoost.Location = new System.Drawing.Point(18, 87);
this.checkBoost.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkBoost.Name = "checkBoost";
this.checkBoost.Size = new System.Drawing.Size(127, 19);
this.checkBoost.TabIndex = 21;
this.checkBoost.Text = "CPU Boost enabled";
this.checkBoost.UseVisualStyleBackColor = true;
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(705, 900);
this.ClientSize = new System.Drawing.Size(390, 441);
this.Controls.Add(this.checkBoost);
this.Controls.Add(this.checkScreen);
this.Controls.Add(this.tableScreen);
this.Controls.Add(this.pictureScreen);
@@ -427,11 +470,12 @@
this.Controls.Add(this.trackBattery);
this.Controls.Add(this.checkStartup);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.MaximizeBox = false;
this.MdiChildrenMinimizedAnchorBottom = false;
this.MinimizeBox = false;
this.Name = "SettingsForm";
this.Padding = new System.Windows.Forms.Padding(10);
this.Padding = new System.Windows.Forms.Padding(5);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -478,5 +522,6 @@
private Button button120Hz;
private Button button60Hz;
private CheckBox checkScreen;
private CheckBox checkBoost;
}
}

View File

@@ -1,5 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics;
using System.Management;
using System.Timers;
namespace GHelper
@@ -48,6 +48,8 @@ namespace GHelper
buttonQuit.Click += ButtonQuit_Click;
checkBoost.Click += CheckBoost_Click;
checkScreen.CheckedChanged += checkScreen_CheckedChanged;
SetTimer();
@@ -55,9 +57,18 @@ namespace GHelper
}
private void CheckBoost_Click(object? sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
NativeMethods.SetCPUBoost(3);
else
NativeMethods.SetCPUBoost(0);
}
private void Button120Hz_Click(object? sender, EventArgs e)
{
SetScreen(120, 1);
SetScreen(1000, 1);
}
private void Button60Hz_Click(object? sender, EventArgs e)
@@ -68,22 +79,58 @@ namespace GHelper
public void SetScreen(int frequency = -1, int overdrive = -1)
{
if (frequency > 0)
int currentFrequency = NativeMethods.GetRefreshRate();
if (currentFrequency < 0) // Laptop screen not detected or has unknown refresh rate
return;
if (frequency >= 1000)
{
frequency = Program.config.getConfig("max_frequency");
if (frequency <= 60)
frequency = 120;
}
if (frequency > 0)
NativeMethods.SetRefreshRate(frequency);
if (overdrive > 0)
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
InitScreen(frequency, overdrive);
InitScreen();
}
public void InitScreen(int frequency = -1, int overdrive = -1)
public void InitBoost()
{
int boost = NativeMethods.GetCPUBoost();
checkBoost.Checked = (boost > 0);
}
public void InitScreen()
{
if (frequency < 0)
frequency = NativeMethods.GetRefreshRate();
int frequency = NativeMethods.GetRefreshRate();
int maxFrequency = Program.config.getConfig("max_frequency");
if (overdrive < 0)
overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
if (frequency < 0)
{
button60Hz.Enabled = false;
button120Hz.Enabled = false;
labelSreen.Text = "Latop Screen: Turned off";
button60Hz.BackColor = SystemColors.ControlLight;
button120Hz.BackColor = SystemColors.ControlLight;
}
else
{
button60Hz.Enabled = true;
button120Hz.Enabled = true;
button60Hz.BackColor = SystemColors.ControlLightLight;
button120Hz.BackColor = SystemColors.ControlLightLight;
labelSreen.Text = "Latop Screen";
}
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
button60Hz.FlatAppearance.BorderSize = buttonInactive;
button120Hz.FlatAppearance.BorderSize = buttonInactive;
@@ -91,10 +138,20 @@ namespace GHelper
if (frequency == 60)
{
button60Hz.FlatAppearance.BorderSize = buttonActive;
} else if (frequency == 120)
}
else
{
if (frequency > 60)
maxFrequency = frequency;
Program.config.setConfig("max_frequency", maxFrequency);
button120Hz.FlatAppearance.BorderSize = buttonActive;
}
}
if (maxFrequency > 60)
{
button120Hz.Text = maxFrequency.ToString() + "Hz + OD";
}
Program.config.setConfig("frequency", frequency);
Program.config.setConfig("overdrive", overdrive);
@@ -158,7 +215,7 @@ namespace GHelper
InitScreen();
this.Left = Screen.FromControl(this).Bounds.Width - 10 - this.Width;
this.Top = Screen.FromControl(this).Bounds.Height - 100 - this.Height;
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
this.Activate();
aTimer.Enabled = true;
}
@@ -204,13 +261,13 @@ namespace GHelper
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1);
}
public void AutoScreen (int Plugged = 1)
public void AutoScreen(int Plugged = 1)
{
int ScreenAuto = Program.config.getConfig("screen_auto");
if (ScreenAuto != 1) return;
if (Plugged == 1)
SetScreen(120, 1);
SetScreen(1000, 1);
else
SetScreen(60, 0);
@@ -233,25 +290,24 @@ namespace GHelper
{
if (eco == 1 && Plugged == 1) // Eco going Standard on plugged
{
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
GPUMode = ASUSWmi.GPUModeStandard;
VisualiseGPUMode(GPUMode);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
Program.config.setConfig("gpu_mode", GPUMode);
}
else if (eco == 0 && Plugged == 0) // Standard going Eco on plugged
{
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
GPUMode = ASUSWmi.GPUModeEco;
VisualiseGPUMode(GPUMode);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
Program.config.setConfig("gpu_mode", GPUMode);
}
}
}
public int InitGPUMode()
{
@@ -337,7 +393,7 @@ namespace GHelper
}
public void VisualiseGPUAuto(int GPUAuto)
public void VisualiseGPUAuto(int GPUAuto)
{
checkGPU.Checked = (GPUAuto == 1);
}
@@ -358,25 +414,23 @@ namespace GHelper
{
case ASUSWmi.GPUModeEco:
buttonEco.FlatAppearance.BorderSize = buttonActive;
labelGPU.Text = "GPU Mode: Eco (iGPU only)";
labelGPU.Text = "GPU Mode: iGPU only";
Program.trayIcon.Icon = GHelper.Properties.Resources.eco;
break;
case ASUSWmi.GPUModeUltimate:
buttonUltimate.FlatAppearance.BorderSize = buttonActive;
labelGPU.Text = "GPU Mode: Ultimate (dGPU exclusive)";
labelGPU.Text = "GPU Mode: dGPU exclusive";
Program.trayIcon.Icon = GHelper.Properties.Resources.ultimate;
break;
default:
buttonStandard.FlatAppearance.BorderSize = buttonActive;
labelGPU.Text = "GPU Mode: Eco (iGPU and dGPU)";
labelGPU.Text = "GPU Mode: iGPU and dGPU";
Program.trayIcon.Icon = GHelper.Properties.Resources.standard;
break;
}
}
private void ButtonSilent_Click(object? sender, EventArgs e)
{
SetPerformanceMode(ASUSWmi.PerformanceSilent);
@@ -400,6 +454,7 @@ namespace GHelper
public void Disable_Ultimate()
{
buttonUltimate.Enabled = false;
buttonUltimate.BackColor = SystemColors.ControlLight;
}
public void SetStartupCheck(bool status)
@@ -419,7 +474,7 @@ namespace GHelper
}
}
public void SetBatteryChargeLimit (int limit = 100)
public void SetBatteryChargeLimit(int limit = 100)
{
if (limit < 50 || limit > 100) limit = 100;
@@ -441,13 +496,9 @@ namespace GHelper
{
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
{
Program.config.setConfig("gpu_auto", 1);
}
else
{
Program.config.setConfig("gpu_auto", 0);
}
}
@@ -455,13 +506,9 @@ namespace GHelper
{
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
{
Program.config.setConfig("screen_auto", 1);
}
else
{
Program.config.setConfig("screen_auto", 0);
}
}
}

BIN
null Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 KiB

After

Width:  |  Height:  |  Size: 813 KiB