Added automatic GPU mode switching, battery charge limit setting, startup scheduling

This commit is contained in:
seerge
2023-02-17 18:18:42 +01:00
parent e802bf72e3
commit e5810647fa
12 changed files with 1724 additions and 325 deletions

View File

@@ -2,30 +2,32 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.22621.0</TargetFramework> <TargetFramework>net6.0-windows8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<IsPublishable>True</IsPublishable> <IsPublishable>True</IsPublishable>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject>Program</StartupObject> <StartupObject>GHelper.Program</StartupObject>
<ApplicationIcon>Resources\standard.ico</ApplicationIcon> <ApplicationIcon>Resources\standard.ico</ApplicationIcon>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<COMReference Include="MMC20"> <None Remove="Resources\eco.ico" />
<WrapperTool>tlbimp</WrapperTool> <None Remove="Resources\icons8-charging-battery-48.png" />
<VersionMinor>0</VersionMinor> <None Remove="Resources\icons8-laptop-48.png" />
<VersionMajor>1</VersionMajor> <None Remove="Resources\icons8-speed-48.png" />
<Guid>8e80422b-cac4-472b-b272-9635f1dfef3b</Guid> <None Remove="Resources\icons8-video-card-48.png" />
<Lcid>0</Lcid> <None Remove="Resources\ultimate.ico" />
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Resources\standard.ico" /> <Content Include="Resources\standard.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -43,4 +45,52 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Resources\eco.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\icons8-charging-battery-48.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\icons8-laptop-48.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\icons8-speed-48.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\icons8-video-card-48.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\ultimate.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project> </Project>

View File

@@ -1,19 +1,9 @@
using System;
using System.Windows.Forms;
using System.Management;
using Microsoft.Win32.TaskScheduler; using Microsoft.Win32.TaskScheduler;
using System.Diagnostics;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Reflection;
using GHelper;
using System.Dynamic;
using System.IO;
using System.Xml.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic;
using System.Diagnostics;
using System.Management;
using System.Reflection.Metadata.Ecma335;
public class ASUSWmi public class ASUSWmi
{ {
@@ -28,6 +18,7 @@ public class ASUSWmi
public const int GPUEco = 0x00090020; public const int GPUEco = 0x00090020;
public const int GPUMux = 0x00090016; public const int GPUMux = 0x00090016;
public const int BatteryLimit = 0x00120057;
public const int PerformanceBalanced = 0; public const int PerformanceBalanced = 0;
public const int PerformanceTurbo = 1; public const int PerformanceTurbo = 1;
@@ -90,15 +81,62 @@ public class ASUSWmi
} }
public class Startup
{
static string taskName = "GSharpHelper";
public Startup()
{
}
public bool IsScheduled()
{
TaskService taskService = new TaskService();
return (taskService.RootFolder.AllTasks.Any(t => t.Name == taskName));
}
public void Schedule()
{
TaskService taskService = new TaskService();
string strExeFilePath = Application.ExecutablePath;
if (strExeFilePath is null) return;
Debug.WriteLine(strExeFilePath);
TaskDefinition td = TaskService.Instance.NewTask();
td.RegistrationInfo.Description = "GSharpHelper Auto Start";
LogonTrigger lt = new LogonTrigger();
td.Triggers.Add(lt);
td.Actions.Add(strExeFilePath);
td.Principal.RunLevel = TaskRunLevel.Highest;
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
}
public void UnSchedule()
{
TaskService taskService = new TaskService();
taskService.RootFolder.DeleteTask(taskName);
}
}
public class AppConfig public class AppConfig
{ {
string appPath; string appPath;
string configFile; string configFile;
public dynamic Config = new ExpandoObject(); public Dictionary<string, object> config = new Dictionary<string, object>();
public AppConfig() { public AppConfig()
{
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper"; appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
configFile = appPath + "\\config.json"; configFile = appPath + "\\config.json";
@@ -109,26 +147,36 @@ public class AppConfig
if (File.Exists(configFile)) if (File.Exists(configFile))
{ {
string text = File.ReadAllText(configFile); string text = File.ReadAllText(configFile);
Config = JsonConvert.DeserializeObject<ExpandoObject>(text); config = JsonConvert.DeserializeObject<Dictionary<string, object>>(text);
} else if (config is null)
initConfig();
}
else
{ {
Config.performance_mode = 0; initConfig();
string jsonString = JsonConvert.SerializeObject(Config);
File.WriteAllText(configFile, jsonString);
} }
} }
private void initConfig()
{
config = new Dictionary<string, object>();
config["performance_mode"] = 0;
string jsonString = JsonConvert.SerializeObject(config);
File.WriteAllText(configFile, jsonString);
}
public int getConfig(string name) public int getConfig(string name)
{ {
var propertyInfo = Config.GetType().GetProperty(name); if (config.ContainsKey(name))
return propertyInfo.GetValue(Config, null); return int.Parse(config[name].ToString());
else return -1;
} }
public void setConfig(string name, int value) public void setConfig(string name, int value)
{ {
((IDictionary<String, Object>)Config).TryAdd(name, value); config[name] = value;
string jsonString = JsonConvert.SerializeObject(Config); string jsonString = JsonConvert.SerializeObject(config);
File.WriteAllText(configFile, jsonString); File.WriteAllText(configFile, jsonString);
} }
@@ -136,7 +184,8 @@ public class AppConfig
} }
namespace GHelper
{
static class Program static class Program
{ {
public static NotifyIcon trayIcon; public static NotifyIcon trayIcon;
@@ -145,6 +194,7 @@ static class Program
public static AppConfig config; public static AppConfig config;
public static SettingsForm settingsForm; public static SettingsForm settingsForm;
public static Startup scheduler;
// The main entry point for the application // The main entry point for the application
public static void Main() public static void Main()
@@ -152,7 +202,7 @@ static class Program
trayIcon = new NotifyIcon trayIcon = new NotifyIcon
{ {
Text = "G14 Helper", Text = "G14 Helper",
Icon = new System.Drawing.Icon("Resources/standard.ico"), Icon = GHelper.Properties.Resources.standard,
Visible = true Visible = true
}; };
@@ -163,52 +213,22 @@ static class Program
wmi = new ASUSWmi(); wmi = new ASUSWmi();
wmi.SubscribeToEvents(WatcherEventArrived); wmi.SubscribeToEvents(WatcherEventArrived);
scheduler = new Startup();
settingsForm = new SettingsForm(); settingsForm = new SettingsForm();
//settingsForm.Show();
int GpuMode = GetGPUMode(); settingsForm.InitGPUMode();
settingsForm.SetPerformanceMode(); settingsForm.SetPerformanceMode(config.getConfig("performance_mode"));
settingsForm.VisualiseGPUMode(GpuMode); settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
settingsForm.FormClosed += SettingsForm_FormClosed; settingsForm.VisualiseGPUAuto(config.getConfig("gpu_auto"));
settingsForm.SetStartupCheck(scheduler.IsScheduled());
Application.Run(); Application.Run();
} }
public static int GetGPUMode ()
{
int eco = wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = wmi.DeviceGet(ASUSWmi.GPUMux);
int GpuMode;
if (mux == 0)
GpuMode = ASUSWmi.GPUModeUltimate;
else
{
if (eco == 1)
GpuMode = ASUSWmi.GPUModeEco;
else
GpuMode = ASUSWmi.GPUModeStandard;
if (mux != 1)
settingsForm.Disable_Ultimate();
}
config.setConfig ("gpu_mode",GpuMode);
return GpuMode;
}
private static void SettingsForm_FormClosed(object? sender, FormClosedEventArgs e)
{
trayIcon.Visible = false;
Application.Exit();
}
static void WatcherEventArrived(object sender, EventArrivedEventArgs e) static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
{ {
@@ -219,10 +239,27 @@ static class Program
switch (EventID) switch (EventID)
{ {
case 56: case 56: // Rog button
case 174: case 174: // FN+F5
CyclePerformanceMode(); settingsForm.BeginInvoke(delegate
{
settingsForm.CyclePerformanceMode();
});
return; return;
case 87: // Battery
settingsForm.BeginInvoke(delegate
{
settingsForm.AutoGPUMode(0);
});
return;
case 88: // Plugged
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
settingsForm.BeginInvoke(delegate
{
settingsForm.AutoGPUMode(1);
});
return;
} }
@@ -230,10 +267,11 @@ static class Program
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e) static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
{ {
if (settingsForm.Visible) if (settingsForm.Visible)
settingsForm.Hide(); else settingsForm.Hide();
else
{ {
settingsForm.Show(); settingsForm.Show();
settingsForm.Activate(); settingsForm.Activate();
@@ -242,13 +280,6 @@ static class Program
} }
static void CyclePerformanceMode()
{
settingsForm.BeginInvoke(delegate
{
settingsForm.SetPerformanceMode(config.getConfig("performance_mode") + 1);
});
}
static void OnExit(object sender, EventArgs e) static void OnExit(object sender, EventArgs e)
{ {
@@ -257,3 +288,4 @@ static class Program
} }
} }
}

123
Properties/Resources.Designer.cs generated Normal file
View File

@@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GHelper.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GHelper.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon eco {
get {
object obj = ResourceManager.GetObject("eco", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_charging_battery_48 {
get {
object obj = ResourceManager.GetObject("icons8-charging-battery-48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_speed_48 {
get {
object obj = ResourceManager.GetObject("icons8-speed-48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_video_card_48 {
get {
object obj = ResourceManager.GetObject("icons8-video-card-48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon standard {
get {
object obj = ResourceManager.GetObject("standard", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon ultimate {
get {
object obj = ResourceManager.GetObject("ultimate", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

139
Properties/Resources.resx Normal file
View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="icons8-charging-battery-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-charging-battery-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="eco" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ultimate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-video-card-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-video-card-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-speed-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

26
Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GHelper.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>

View File

@@ -1 +1,47 @@
# GHelper # G14-Helper
Designed for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models.
A tiny system tray utility that allows you set performance and GPU profiles for your laptop. Same as ASUS Armory Crate does but without it completely!.
## Performance Profile switching
Profiles are **same** as in Armory Crate, including default fan curves
1. Silent (minimal or no fans, 45W PPT to CPU)
2. Balanced (balanced fans, up to 45W PPT to CPU)
3. Turbo (intense fans, 125W PPT total, up to 80W PPT to CPU)
## GPU Mode switching
1. Eco mode : only low power iGPU (Radeon 680u) enabled, iGPU drives built in display
2. Standard mode (Windows Hybrid) : iGPU and dGPU (Radeon 6700s/6800s) enabled, iGPU drives built in display
3. Ultimate mode: iGPU and dGPU enabled, but dGPU drives built in display
## Extras
1. **Maximum battery charge rate** limit (60% / 80% / 100%) to preserve your battery
2. CPU and GPU relative fan speed monitoring
3. Automatic switching of Standard/Eco GPU modes when laptop is plugged / unplugged!
4. Start with windows (optional)
## How to install
1. Download latest release from https://github.com/seerge/g14-helper/releases
2. Unzip to a folder of your choice
3. Run **GHelper.exe**
Note: Uses low level ASUS WMI commands to do switching and doens't require Armory Crate to be isntalled at all.
Therefore requires Administrator priveledges on Windows to run.
I don`t have Microsoft certificate to sign app yet, so if you set a warning from Windows Defender on launch (Windows Protected your PC), click More Info -> Run anyway.
Alternatively you can comile and run project by yourself :)
![Screenshot](https://github.com/seerge/g14-helper/blob/main/screenshot.png)
Settings are located in APPDATA\ROAMING
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

383
Settings.Designer.cs generated
View File

@@ -28,129 +28,106 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupPerf = new System.Windows.Forms.GroupBox(); this.checkStartup = new System.Windows.Forms.CheckBox();
this.labelCPUFan = new System.Windows.Forms.Label(); this.trackBattery = new System.Windows.Forms.TrackBar();
this.tablePerf = new System.Windows.Forms.TableLayoutPanel(); this.labelBattery = new System.Windows.Forms.Label();
this.buttonTurbo = new System.Windows.Forms.Button(); this.labelBatteryLimit = new System.Windows.Forms.Label();
this.buttonBalanced = new System.Windows.Forms.Button(); this.pictureBattery = new System.Windows.Forms.PictureBox();
this.buttonSilent = new System.Windows.Forms.Button();
this.groupGPU = new System.Windows.Forms.GroupBox();
this.labelGPUFan = new System.Windows.Forms.Label(); this.labelGPUFan = new System.Windows.Forms.Label();
this.tableGPU = new System.Windows.Forms.TableLayoutPanel(); this.tableGPU = new System.Windows.Forms.TableLayoutPanel();
this.buttonUltimate = new System.Windows.Forms.Button(); this.buttonUltimate = new System.Windows.Forms.Button();
this.buttonStandard = new System.Windows.Forms.Button(); this.buttonStandard = new System.Windows.Forms.Button();
this.buttonEco = new System.Windows.Forms.Button(); this.buttonEco = new System.Windows.Forms.Button();
this.groupPerf.SuspendLayout(); this.labelGPU = new System.Windows.Forms.Label();
this.tablePerf.SuspendLayout(); this.pictureGPU = new System.Windows.Forms.PictureBox();
this.groupGPU.SuspendLayout(); this.labelCPUFan = new System.Windows.Forms.Label();
this.tablePerf = new System.Windows.Forms.TableLayoutPanel();
this.buttonTurbo = new System.Windows.Forms.Button();
this.buttonBalanced = new System.Windows.Forms.Button();
this.buttonSilent = new System.Windows.Forms.Button();
this.picturePerf = new System.Windows.Forms.PictureBox();
this.labelPerf = new System.Windows.Forms.Label();
this.checkGPU = new System.Windows.Forms.CheckBox();
this.buttonQuit = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.trackBattery)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBattery)).BeginInit();
this.tableGPU.SuspendLayout(); this.tableGPU.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureGPU)).BeginInit();
this.tablePerf.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picturePerf)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupPerf // checkStartup
// //
this.groupPerf.Controls.Add(this.labelCPUFan); this.checkStartup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.groupPerf.Controls.Add(this.tablePerf); this.checkStartup.AutoSize = true;
this.groupPerf.Dock = System.Windows.Forms.DockStyle.Top; this.checkStartup.Location = new System.Drawing.Point(34, 640);
this.groupPerf.Location = new System.Drawing.Point(10, 10); this.checkStartup.Name = "checkStartup";
this.groupPerf.Margin = new System.Windows.Forms.Padding(10); this.checkStartup.Size = new System.Drawing.Size(206, 36);
this.groupPerf.Name = "groupPerf"; this.checkStartup.TabIndex = 2;
this.groupPerf.Padding = new System.Windows.Forms.Padding(10); this.checkStartup.Text = "Run on Startup";
this.groupPerf.Size = new System.Drawing.Size(666, 188); this.checkStartup.UseVisualStyleBackColor = true;
this.groupPerf.TabIndex = 0; this.checkStartup.CheckedChanged += new System.EventHandler(this.checkStartup_CheckedChanged);
this.groupPerf.TabStop = false;
this.groupPerf.Text = "Performance Mode";
// //
// labelCPUFan // trackBattery
// //
this.labelCPUFan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.trackBattery.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.labelCPUFan.AutoSize = true; | System.Windows.Forms.AnchorStyles.Right)));
this.labelCPUFan.Location = new System.Drawing.Point(491, 28); this.trackBattery.LargeChange = 20;
this.labelCPUFan.Name = "labelCPUFan"; this.trackBattery.Location = new System.Drawing.Point(23, 532);
this.labelCPUFan.Size = new System.Drawing.Size(154, 32); this.trackBattery.Maximum = 100;
this.labelCPUFan.TabIndex = 2; this.trackBattery.Minimum = 50;
this.labelCPUFan.Text = "CPU Fan : 0%"; this.trackBattery.Name = "trackBattery";
this.trackBattery.Size = new System.Drawing.Size(702, 90);
this.trackBattery.SmallChange = 10;
this.trackBattery.TabIndex = 3;
this.trackBattery.TickFrequency = 10;
this.trackBattery.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
this.trackBattery.Value = 100;
// //
// tablePerf // labelBattery
// //
this.tablePerf.ColumnCount = 3; this.labelBattery.AutoSize = true;
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.labelBattery.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.labelBattery.Location = new System.Drawing.Point(83, 486);
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.labelBattery.Name = "labelBattery";
this.tablePerf.Controls.Add(this.buttonTurbo, 2, 0); this.labelBattery.Size = new System.Drawing.Size(248, 32);
this.tablePerf.Controls.Add(this.buttonBalanced, 1, 0); this.labelBattery.TabIndex = 4;
this.tablePerf.Controls.Add(this.buttonSilent, 0, 0); this.labelBattery.Text = "Battery Charge Limit";
this.tablePerf.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tablePerf.Location = new System.Drawing.Point(10, 72);
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(646, 106);
this.tablePerf.TabIndex = 0;
// //
// buttonTurbo // labelBatteryLimit
// //
this.buttonTurbo.Dock = System.Windows.Forms.DockStyle.Fill; this.labelBatteryLimit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonTurbo.FlatAppearance.BorderSize = 0; this.labelBatteryLimit.AutoSize = true;
this.buttonTurbo.Location = new System.Drawing.Point(440, 10); this.labelBatteryLimit.Location = new System.Drawing.Point(647, 484);
this.buttonTurbo.Margin = new System.Windows.Forms.Padding(10); this.labelBatteryLimit.Name = "labelBatteryLimit";
this.buttonTurbo.Name = "buttonTurbo"; this.labelBatteryLimit.Size = new System.Drawing.Size(73, 32);
this.buttonTurbo.Size = new System.Drawing.Size(196, 86); this.labelBatteryLimit.TabIndex = 5;
this.buttonTurbo.TabIndex = 2; this.labelBatteryLimit.Text = "100%";
this.buttonTurbo.Text = "Turbo";
this.buttonTurbo.UseVisualStyleBackColor = true;
// //
// buttonBalanced // pictureBattery
// //
this.buttonBalanced.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.pictureBattery.Image = global::GHelper.Properties.Resources.icons8_charging_battery_48;
this.buttonBalanced.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBattery.Location = new System.Drawing.Point(32, 478);
this.buttonBalanced.FlatAppearance.BorderSize = 0; this.pictureBattery.Name = "pictureBattery";
this.buttonBalanced.Location = new System.Drawing.Point(225, 10); this.pictureBattery.Size = new System.Drawing.Size(48, 48);
this.buttonBalanced.Margin = new System.Windows.Forms.Padding(10); this.pictureBattery.TabIndex = 6;
this.buttonBalanced.Name = "buttonBalanced"; this.pictureBattery.TabStop = false;
this.buttonBalanced.Size = new System.Drawing.Size(195, 86);
this.buttonBalanced.TabIndex = 1;
this.buttonBalanced.Text = "Balanced";
this.buttonBalanced.UseVisualStyleBackColor = false;
//
// buttonSilent
//
this.buttonSilent.CausesValidation = false;
this.buttonSilent.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonSilent.FlatAppearance.BorderSize = 0;
this.buttonSilent.Location = new System.Drawing.Point(10, 10);
this.buttonSilent.Margin = new System.Windows.Forms.Padding(10);
this.buttonSilent.Name = "buttonSilent";
this.buttonSilent.Size = new System.Drawing.Size(195, 86);
this.buttonSilent.TabIndex = 0;
this.buttonSilent.Text = "Silent";
this.buttonSilent.UseVisualStyleBackColor = true;
//
// groupGPU
//
this.groupGPU.Controls.Add(this.labelGPUFan);
this.groupGPU.Controls.Add(this.tableGPU);
this.groupGPU.Dock = System.Windows.Forms.DockStyle.Top;
this.groupGPU.Location = new System.Drawing.Point(10, 198);
this.groupGPU.Margin = new System.Windows.Forms.Padding(10);
this.groupGPU.Name = "groupGPU";
this.groupGPU.Padding = new System.Windows.Forms.Padding(10);
this.groupGPU.Size = new System.Drawing.Size(666, 188);
this.groupGPU.TabIndex = 1;
this.groupGPU.TabStop = false;
this.groupGPU.Text = "GPU Mode";
// //
// labelGPUFan // labelGPUFan
// //
this.labelGPUFan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.labelGPUFan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelGPUFan.AutoSize = true; this.labelGPUFan.AutoSize = true;
this.labelGPUFan.Location = new System.Drawing.Point(491, 33); this.labelGPUFan.Location = new System.Drawing.Point(566, 242);
this.labelGPUFan.Name = "labelGPUFan"; this.labelGPUFan.Name = "labelGPUFan";
this.labelGPUFan.Size = new System.Drawing.Size(155, 32); this.labelGPUFan.Size = new System.Drawing.Size(155, 32);
this.labelGPUFan.TabIndex = 3; this.labelGPUFan.TabIndex = 8;
this.labelGPUFan.Text = "GPU Fan : 0%"; this.labelGPUFan.Text = "GPU Fan : 0%";
// //
// tableGPU // tableGPU
// //
this.tableGPU.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableGPU.ColumnCount = 3; this.tableGPU.ColumnCount = 3;
this.tableGPU.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.tableGPU.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableGPU.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.tableGPU.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
@@ -158,59 +135,210 @@
this.tableGPU.Controls.Add(this.buttonUltimate, 2, 0); this.tableGPU.Controls.Add(this.buttonUltimate, 2, 0);
this.tableGPU.Controls.Add(this.buttonStandard, 1, 0); this.tableGPU.Controls.Add(this.buttonStandard, 1, 0);
this.tableGPU.Controls.Add(this.buttonEco, 0, 0); this.tableGPU.Controls.Add(this.buttonEco, 0, 0);
this.tableGPU.Dock = System.Windows.Forms.DockStyle.Bottom; this.tableGPU.Location = new System.Drawing.Point(23, 289);
this.tableGPU.Location = new System.Drawing.Point(10, 72);
this.tableGPU.Name = "tableGPU"; this.tableGPU.Name = "tableGPU";
this.tableGPU.RowCount = 1; this.tableGPU.RowCount = 1;
this.tableGPU.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F)); this.tableGPU.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F));
this.tableGPU.Size = new System.Drawing.Size(646, 106); this.tableGPU.Size = new System.Drawing.Size(702, 106);
this.tableGPU.TabIndex = 0; this.tableGPU.TabIndex = 7;
// //
// buttonUltimate // buttonUltimate
// //
this.buttonUltimate.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.buttonUltimate.Dock = System.Windows.Forms.DockStyle.Fill; this.buttonUltimate.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonUltimate.FlatAppearance.BorderSize = 0; this.buttonUltimate.FlatAppearance.BorderSize = 0;
this.buttonUltimate.Location = new System.Drawing.Point(440, 10); this.buttonUltimate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonUltimate.Location = new System.Drawing.Point(478, 10);
this.buttonUltimate.Margin = new System.Windows.Forms.Padding(10); this.buttonUltimate.Margin = new System.Windows.Forms.Padding(10);
this.buttonUltimate.Name = "buttonUltimate"; this.buttonUltimate.Name = "buttonUltimate";
this.buttonUltimate.Size = new System.Drawing.Size(196, 86); this.buttonUltimate.Size = new System.Drawing.Size(214, 86);
this.buttonUltimate.TabIndex = 2; this.buttonUltimate.TabIndex = 2;
this.buttonUltimate.Text = "Ultimate"; this.buttonUltimate.Text = "Ultimate";
this.buttonUltimate.UseVisualStyleBackColor = true; this.buttonUltimate.UseVisualStyleBackColor = false;
// //
// buttonStandard // buttonStandard
// //
this.buttonStandard.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.buttonStandard.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.buttonStandard.Dock = System.Windows.Forms.DockStyle.Fill; this.buttonStandard.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonStandard.FlatAppearance.BorderSize = 0; this.buttonStandard.FlatAppearance.BorderSize = 0;
this.buttonStandard.Location = new System.Drawing.Point(225, 10); this.buttonStandard.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonStandard.Location = new System.Drawing.Point(244, 10);
this.buttonStandard.Margin = new System.Windows.Forms.Padding(10); this.buttonStandard.Margin = new System.Windows.Forms.Padding(10);
this.buttonStandard.Name = "buttonStandard"; this.buttonStandard.Name = "buttonStandard";
this.buttonStandard.Size = new System.Drawing.Size(195, 86); this.buttonStandard.Size = new System.Drawing.Size(214, 86);
this.buttonStandard.TabIndex = 1; this.buttonStandard.TabIndex = 1;
this.buttonStandard.Text = "Standard"; this.buttonStandard.Text = "Standard";
this.buttonStandard.UseVisualStyleBackColor = false; this.buttonStandard.UseVisualStyleBackColor = false;
// //
// buttonEco // buttonEco
// //
this.buttonEco.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.buttonEco.CausesValidation = false; this.buttonEco.CausesValidation = false;
this.buttonEco.Dock = System.Windows.Forms.DockStyle.Fill; this.buttonEco.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonEco.FlatAppearance.BorderSize = 0; this.buttonEco.FlatAppearance.BorderSize = 0;
this.buttonEco.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonEco.Location = new System.Drawing.Point(10, 10); this.buttonEco.Location = new System.Drawing.Point(10, 10);
this.buttonEco.Margin = new System.Windows.Forms.Padding(10); this.buttonEco.Margin = new System.Windows.Forms.Padding(10);
this.buttonEco.Name = "buttonEco"; this.buttonEco.Name = "buttonEco";
this.buttonEco.Size = new System.Drawing.Size(195, 86); this.buttonEco.Size = new System.Drawing.Size(214, 86);
this.buttonEco.TabIndex = 0; this.buttonEco.TabIndex = 0;
this.buttonEco.Text = "Eco"; this.buttonEco.Text = "Eco";
this.buttonEco.UseVisualStyleBackColor = true; this.buttonEco.UseVisualStyleBackColor = false;
//
// labelGPU
//
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, 242);
this.labelGPU.Name = "labelGPU";
this.labelGPU.Size = new System.Drawing.Size(136, 32);
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(29, 234);
this.pictureGPU.Name = "pictureGPU";
this.pictureGPU.Size = new System.Drawing.Size(48, 48);
this.pictureGPU.TabIndex = 10;
this.pictureGPU.TabStop = false;
//
// labelCPUFan
//
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(568, 39);
this.labelCPUFan.Name = "labelCPUFan";
this.labelCPUFan.Size = new System.Drawing.Size(154, 32);
this.labelCPUFan.TabIndex = 12;
this.labelCPUFan.Text = "CPU Fan : 0%";
//
// tablePerf
//
this.tablePerf.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tablePerf.ColumnCount = 3;
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
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, 90);
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(702, 106);
this.tablePerf.TabIndex = 11;
//
// buttonTurbo
//
this.buttonTurbo.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.buttonTurbo.Dock = System.Windows.Forms.DockStyle.Fill;
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(478, 10);
this.buttonTurbo.Margin = new System.Windows.Forms.Padding(10);
this.buttonTurbo.Name = "buttonTurbo";
this.buttonTurbo.Size = new System.Drawing.Size(214, 86);
this.buttonTurbo.TabIndex = 2;
this.buttonTurbo.Text = "Turbo";
this.buttonTurbo.UseVisualStyleBackColor = false;
//
// buttonBalanced
//
this.buttonBalanced.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.buttonBalanced.Dock = System.Windows.Forms.DockStyle.Fill;
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(244, 10);
this.buttonBalanced.Margin = new System.Windows.Forms.Padding(10);
this.buttonBalanced.Name = "buttonBalanced";
this.buttonBalanced.Size = new System.Drawing.Size(214, 86);
this.buttonBalanced.TabIndex = 1;
this.buttonBalanced.Text = "Balanced";
this.buttonBalanced.UseVisualStyleBackColor = false;
//
// buttonSilent
//
this.buttonSilent.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.buttonSilent.CausesValidation = false;
this.buttonSilent.Dock = System.Windows.Forms.DockStyle.Fill;
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.Name = "buttonSilent";
this.buttonSilent.Size = new System.Drawing.Size(214, 86);
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(30, 29);
this.picturePerf.Name = "picturePerf";
this.picturePerf.Size = new System.Drawing.Size(48, 48);
this.picturePerf.TabIndex = 14;
this.picturePerf.TabStop = false;
//
// labelPerf
//
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.Name = "labelPerf";
this.labelPerf.Size = new System.Drawing.Size(234, 32);
this.labelPerf.TabIndex = 13;
this.labelPerf.Text = "Performance Mode";
//
// checkGPU
//
this.checkGPU.AutoSize = true;
this.checkGPU.Location = new System.Drawing.Point(34, 400);
this.checkGPU.Name = "checkGPU";
this.checkGPU.Size = new System.Drawing.Size(614, 36);
this.checkGPU.TabIndex = 15;
this.checkGPU.Text = "Switch to Eco on battery and Standard when plugged";
this.checkGPU.UseVisualStyleBackColor = true;
this.checkGPU.CheckedChanged += new System.EventHandler(this.checkGPU_CheckedChanged);
//
// buttonQuit
//
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(602, 634);
this.buttonQuit.Name = "buttonQuit";
this.buttonQuit.Size = new System.Drawing.Size(120, 46);
this.buttonQuit.TabIndex = 16;
this.buttonQuit.Text = "Quit";
this.buttonQuit.UseVisualStyleBackColor = false;
// //
// SettingsForm // SettingsForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(686, 636); this.ClientSize = new System.Drawing.Size(756, 704);
this.Controls.Add(this.groupGPU); this.Controls.Add(this.buttonQuit);
this.Controls.Add(this.groupPerf); this.Controls.Add(this.checkGPU);
this.Controls.Add(this.picturePerf);
this.Controls.Add(this.labelPerf);
this.Controls.Add(this.labelCPUFan);
this.Controls.Add(this.tablePerf);
this.Controls.Add(this.pictureGPU);
this.Controls.Add(this.labelGPU);
this.Controls.Add(this.labelGPUFan);
this.Controls.Add(this.tableGPU);
this.Controls.Add(this.pictureBattery);
this.Controls.Add(this.labelBatteryLimit);
this.Controls.Add(this.labelBattery);
this.Controls.Add(this.trackBattery);
this.Controls.Add(this.checkStartup);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MdiChildrenMinimizedAnchorBottom = false; this.MdiChildrenMinimizedAnchorBottom = false;
@@ -222,29 +350,38 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "G14 Helper"; this.Text = "G14 Helper";
this.Load += new System.EventHandler(this.Settings_Load); this.Load += new System.EventHandler(this.Settings_Load);
this.groupPerf.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.trackBattery)).EndInit();
this.groupPerf.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBattery)).EndInit();
this.tablePerf.ResumeLayout(false);
this.groupGPU.ResumeLayout(false);
this.groupGPU.PerformLayout();
this.tableGPU.ResumeLayout(false); this.tableGPU.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureGPU)).EndInit();
this.tablePerf.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picturePerf)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private CheckBox checkStartup;
private GroupBox groupPerf; private TrackBar trackBattery;
private TableLayoutPanel tablePerf; private Label labelBattery;
private Button buttonSilent; private Label labelBatteryLimit;
private Button buttonTurbo; private PictureBox pictureBattery;
private Button buttonBalanced; private Label labelGPUFan;
private GroupBox groupGPU;
private TableLayoutPanel tableGPU; private TableLayoutPanel tableGPU;
private Button buttonUltimate; private Button buttonUltimate;
private Button buttonStandard; private Button buttonStandard;
private Button buttonEco; private Button buttonEco;
private Label labelGPU;
private PictureBox pictureGPU;
private Label labelCPUFan; private Label labelCPUFan;
private Label labelGPUFan; private TableLayoutPanel tablePerf;
private Button buttonTurbo;
private Button buttonBalanced;
private Button buttonSilent;
private PictureBox picturePerf;
private Label labelPerf;
private CheckBox checkGPU;
private Button buttonQuit;
} }
} }

View File

@@ -1,32 +1,36 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Dynamic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Timers; using System.Timers;
using System.Windows.Forms;
using Windows.ApplicationModel.Store;
namespace GHelper namespace GHelper
{ {
public partial class SettingsForm : Form public partial class SettingsForm : Form
{ {
static Color colorActive = Color.LightGray; static Color colorEco = Color.FromArgb(255, 6, 180, 138);
static Color colorStandard = Color.FromArgb(255, 58, 174, 239);
static Color colorTurbo = Color.FromArgb(255, 255, 32, 32);
static System.Timers.Timer aTimer; static int buttonInactive = 0;
static int buttonActive = 5;
static System.Timers.Timer aTimer = default!;
public SettingsForm() public SettingsForm()
{ {
InitializeComponent(); InitializeComponent();
FormClosing += SettingsForm_FormClosing;
buttonSilent.FlatAppearance.BorderColor = colorEco;
buttonBalanced.FlatAppearance.BorderColor = colorStandard;
buttonTurbo.FlatAppearance.BorderColor = colorTurbo;
buttonEco.FlatAppearance.BorderColor = colorEco;
buttonStandard.FlatAppearance.BorderColor = colorStandard;
buttonUltimate.FlatAppearance.BorderColor = colorTurbo;
buttonSilent.Click += ButtonSilent_Click; buttonSilent.Click += ButtonSilent_Click;
buttonBalanced.Click += ButtonBalanced_Click; buttonBalanced.Click += ButtonBalanced_Click;
buttonTurbo.Click += ButtonTurbo_Click; buttonTurbo.Click += ButtonTurbo_Click;
@@ -37,11 +41,31 @@ namespace GHelper
VisibleChanged += SettingsForm_VisibleChanged; VisibleChanged += SettingsForm_VisibleChanged;
trackBattery.Scroll += trackBatteryChange;
buttonQuit.Click += ButtonQuit_Click;
SetTimer(); SetTimer();
} }
private void ButtonQuit_Click(object? sender, EventArgs e)
{
Close();
Program.trayIcon.Visible = false;
Application.Exit();
}
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
Hide();
}
}
private void ButtonUltimate_Click(object? sender, EventArgs e) private void ButtonUltimate_Click(object? sender, EventArgs e)
{ {
SetGPUMode(ASUSWmi.GPUModeUltimate); SetGPUMode(ASUSWmi.GPUModeUltimate);
@@ -85,7 +109,8 @@ namespace GHelper
this.Top = Screen.FromControl(this).Bounds.Height - 100 - this.Height; this.Top = Screen.FromControl(this).Bounds.Height - 100 - this.Height;
this.Activate(); this.Activate();
aTimer.Enabled = true; aTimer.Enabled = true;
} else }
else
{ {
aTimer.Enabled = false; aTimer.Enabled = false;
} }
@@ -94,24 +119,23 @@ namespace GHelper
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced) public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced)
{ {
buttonSilent.UseVisualStyleBackColor = true; buttonSilent.FlatAppearance.BorderSize = buttonInactive;
buttonBalanced.UseVisualStyleBackColor = true; buttonBalanced.FlatAppearance.BorderSize = buttonInactive;
buttonTurbo.UseVisualStyleBackColor = true; buttonTurbo.FlatAppearance.BorderSize = buttonInactive;
switch (PerformanceMode) switch (PerformanceMode)
{ {
case ASUSWmi.PerformanceSilent: case ASUSWmi.PerformanceSilent:
buttonSilent.BackColor = colorActive; buttonSilent.FlatAppearance.BorderSize = buttonActive;
groupPerf.Text = "Peformance Mode: Silent"; labelPerf.Text = "Peformance Mode: Silent";
break; break;
case ASUSWmi.PerformanceTurbo: case ASUSWmi.PerformanceTurbo:
buttonTurbo.BackColor = colorActive; buttonTurbo.FlatAppearance.BorderSize = buttonActive;
groupPerf.Text = "Peformance Mode: Turbo"; labelPerf.Text = "Peformance Mode: Turbo";
break; break;
default: default:
buttonBalanced.BackColor = colorActive; buttonBalanced.FlatAppearance.BorderSize = buttonActive;
groupPerf.Text = "Peformance Mode: Balanced"; labelPerf.Text = "Peformance Mode: Balanced";
PerformanceMode = ASUSWmi.PerformanceBalanced; PerformanceMode = ASUSWmi.PerformanceBalanced;
break; break;
} }
@@ -123,6 +147,75 @@ namespace GHelper
} }
public void CyclePerformanceMode()
{
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1);
}
public void AutoGPUMode(int Plugged = 1)
{
int GpuAuto = Program.config.getConfig("gpu_auto");
if (GpuAuto != 1) return;
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
int GPUMode;
if (mux == 0) // GPU in Ultimate, ignore
return;
else
{
if (eco == 1 && Plugged == 1) // Eco going Standard on plugged
{
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
{
GPUMode = ASUSWmi.GPUModeEco;
VisualiseGPUMode(GPUMode);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
Program.config.setConfig("gpu_mode", GPUMode);
}
}
}
public int InitGPUMode()
{
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
int GpuMode;
if (mux == 0)
GpuMode = ASUSWmi.GPUModeUltimate;
else
{
if (eco == 1)
GpuMode = ASUSWmi.GPUModeEco;
else
GpuMode = ASUSWmi.GPUModeStandard;
if (mux != 1)
Disable_Ultimate();
}
Program.config.setConfig("gpu_mode", GpuMode);
VisualiseGPUMode(GpuMode);
return GpuMode;
}
public void SetGPUMode(int GPUMode = ASUSWmi.GPUModeStandard) public void SetGPUMode(int GPUMode = ASUSWmi.GPUModeStandard)
{ {
@@ -143,7 +236,8 @@ namespace GHelper
restart = true; restart = true;
changed = true; changed = true;
} }
} else if (GPUMode == ASUSWmi.GPUModeUltimate) }
else if (GPUMode == ASUSWmi.GPUModeUltimate)
{ {
DialogResult dialogResult = MessageBox.Show(" Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show(" Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
@@ -153,12 +247,14 @@ namespace GHelper
changed = true; changed = true;
} }
} else if (GPUMode == ASUSWmi.GPUModeEco) }
else if (GPUMode == ASUSWmi.GPUModeEco)
{ {
VisualiseGPUMode(GPUMode); VisualiseGPUMode(GPUMode);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1); Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
changed = true; changed = true;
} else if (GPUMode == ASUSWmi.GPUModeStandard) }
else if (GPUMode == ASUSWmi.GPUModeStandard)
{ {
VisualiseGPUMode(GPUMode); VisualiseGPUMode(GPUMode);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0); Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
@@ -176,34 +272,42 @@ namespace GHelper
} }
public void VisualiseGPUAuto(int GPUAuto)
{
checkGPU.Checked = (GPUAuto == 1);
}
public void VisualiseGPUMode(int GPUMode) public void VisualiseGPUMode(int GPUMode)
{ {
buttonEco.UseVisualStyleBackColor = true; buttonEco.FlatAppearance.BorderSize = buttonInactive;
buttonStandard.UseVisualStyleBackColor = true; buttonStandard.FlatAppearance.BorderSize = buttonInactive;
buttonUltimate.UseVisualStyleBackColor = true; buttonUltimate.FlatAppearance.BorderSize = buttonInactive;
switch (GPUMode) switch (GPUMode)
{ {
case ASUSWmi.GPUModeEco: case ASUSWmi.GPUModeEco:
buttonEco.BackColor = colorActive; buttonEco.FlatAppearance.BorderSize = buttonActive;
groupGPU.Text = "GPU Mode: Eco (iGPU only)"; labelGPU.Text = "GPU Mode: Eco (iGPU only)";
Program.trayIcon.Icon = new System.Drawing.Icon("Resources/eco.ico"); Program.trayIcon.Icon = GHelper.Properties.Resources.eco;
break; break;
case ASUSWmi.GPUModeUltimate: case ASUSWmi.GPUModeUltimate:
buttonUltimate.BackColor = colorActive; buttonUltimate.FlatAppearance.BorderSize = buttonActive;
groupGPU.Text = "GPU Mode: Ultimate (dGPU exclusive)"; labelGPU.Text = "GPU Mode: Ultimate (dGPU exclusive)";
Program.trayIcon.Icon = new System.Drawing.Icon("Resources/ultimate.ico"); Program.trayIcon.Icon = GHelper.Properties.Resources.ultimate;
break; break;
default: default:
buttonStandard.BackColor = colorActive; buttonStandard.FlatAppearance.BorderSize = buttonActive;
groupGPU.Text = "GPU Mode: Eco (iGPU and dGPU)"; labelGPU.Text = "GPU Mode: Eco (iGPU and dGPU)";
Program.trayIcon.Icon = new System.Drawing.Icon("Resources/standard.ico"); Program.trayIcon.Icon = GHelper.Properties.Resources.standard;
break; break;
} }
} }
private void ButtonSilent_Click(object? sender, EventArgs e) private void ButtonSilent_Click(object? sender, EventArgs e)
{ {
SetPerformanceMode(ASUSWmi.PerformanceSilent); SetPerformanceMode(ASUSWmi.PerformanceSilent);
@@ -229,6 +333,54 @@ namespace GHelper
buttonUltimate.Enabled = false; buttonUltimate.Enabled = false;
} }
public void SetStartupCheck(bool status)
{
checkStartup.Checked = status;
}
private void checkStartup_CheckedChanged(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
{
Program.scheduler.Schedule();
}
else
{
Program.scheduler.UnSchedule();
}
}
public void SetBatteryChargeLimit (int limit = 100)
{
if (limit < 50 || limit > 100) limit = 100;
labelBatteryLimit.Text = limit.ToString() + "%";
trackBattery.Value = limit;
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
Program.config.setConfig("charge_limit", limit);
}
private void trackBatteryChange(object sender, EventArgs e)
{
TrackBar bar = (TrackBar)sender;
SetBatteryChargeLimit(bar.Value);
}
private void checkGPU_CheckedChanged(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
{
Program.config.setConfig("gpu_auto", 1);
}
else
{
Program.config.setConfig("gpu_auto", 0);
}
}
} }

View File

@@ -0,0 +1 @@
ps2exe .\ghelper.ps1 g14-helper.exe -title 'G14 Helper' -DPIAware -winFormsDPIAware -requireAdmin -iconFile 'standard.ico' -noConsole -copyright 'G14 Helper Tool' -noOutput

687
old-ps1-script/ghelper.ps1 Normal file

File diff suppressed because one or more lines are too long

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB