Compare commits

..

11 Commits

Author SHA1 Message Date
seerge
bc1f3ab530 Merge pull request #14 from Albert24GG/notification-feature
Send notification on performance mode cycling
2023-02-21 23:13:49 +01:00
seerge
3cd62bc9e1 Merge branch 'main' into notification-feature 2023-02-21 23:12:55 +01:00
seerge
16f6f3f934 Merge branch 'main' of https://github.com/seerge/g14-helper 2023-02-21 21:54:16 +01:00
seerge
1f4afedc1d Sensor refresh timers 2023-02-21 21:54:13 +01:00
Albert24GG
c705ce2b5b Send notification on performance mode cycling 2023-02-21 22:51:52 +02:00
seerge
75942ebdb2 Update README.md 2023-02-21 20:07:49 +01:00
seerge
6d142213c8 Minor fix 2023-02-21 19:40:16 +01:00
seerge
bfcb97b158 Update README.md 2023-02-21 19:35:18 +01:00
seerge
f97765c5c2 Performance fix 2023-02-21 19:24:43 +01:00
seerge
19a8b0dc22 Update README.md 2023-02-21 19:15:43 +01:00
seerge
f209f211b5 Added CPU / GPU temps monitoring and Charge/discharge rates in Watts 2023-02-21 19:11:50 +01:00
14 changed files with 519 additions and 83 deletions

View File

@@ -2,14 +2,16 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>True</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<IsPublishable>True</IsPublishable>
<ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject>GHelper.Program</StartupObject>
<ApplicationIcon>Resources\standard.ico</ApplicationIcon>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<Platforms>AnyCPU;x64</Platforms>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
@@ -24,13 +26,15 @@
<ItemGroup>
<Content Include="Resources\standard.ico">
<Content Include="favicon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="hidlibrary" Version="3.3.40" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<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

@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33403.182
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GHelper", "GHelper.csproj", "{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GHelper", "GHelper.csproj", "{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B6E44CC6-5D28-4CB9-8EE2-BE9D6238E2D6}"
ProjectSection(SolutionItems) = preProject
@@ -13,13 +13,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.ActiveCfg = Release|x64
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.Build.0 = Release|x64
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.Build.0 = Release|Any CPU
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x64.ActiveCfg = Release|x64
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -1,8 +1,9 @@
using HidLibrary;
using LibreHardwareMonitor.Hardware;
using Microsoft.Win32.TaskScheduler;
using System.Diagnostics;
using System.Management;
using System.Runtime.InteropServices;
using HidLibrary;
using System.Text.Json;
public class ASUSWmi
@@ -224,6 +225,13 @@ public class NativeMethods
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
int 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 PowerReadACValueIndex(IntPtr RootPowerKey,
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
@@ -232,14 +240,15 @@ public class NativeMethods
out IntPtr AcValueIndex
);
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
static extern UInt32 PowerWriteACValueIndex(IntPtr RootPowerKey,
static extern UInt32 PowerReadDCValueIndex(IntPtr RootPowerKey,
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
int AcValueIndex);
out IntPtr AcValueIndex
);
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey,
@@ -410,7 +419,7 @@ public class NativeMethods
{
Guid activeSchemeGuid = GetActiveScheme();
var hr = PowerWriteACValueIndex(
var hrAC = PowerWriteACValueIndex(
IntPtr.Zero,
activeSchemeGuid,
GUID_CPU,
@@ -418,6 +427,17 @@ public class NativeMethods
boost);
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
var hrDC = PowerWriteDCValueIndex(
IntPtr.Zero,
activeSchemeGuid,
GUID_CPU,
GUID_BOOST,
boost);
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
}
}
@@ -432,6 +452,7 @@ public class Aura
public const int Breathe = 1;
public const int Strobe = 2;
public const int Rainbow = 3;
public const int Dingding = 10;
public const int SpeedSlow = 0;
public const int SpeedMedium = 1;
@@ -489,6 +510,106 @@ public class Aura
}
public class UpdateVisitor : IVisitor
{
public void VisitComputer(IComputer computer)
{
computer.Traverse(this);
}
public void VisitHardware(IHardware hardware)
{
hardware.Update();
foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this);
}
public void VisitSensor(ISensor sensor) { }
public void VisitParameter(IParameter parameter) { }
}
public class HardwareMonitor
{
Computer computer;
public float? cpuTemp = -1;
public float? gpuTemp = -1;
public float? batteryDischarge = -1;
public float? batteryCharge = -1;
public HardwareMonitor()
{
computer = new Computer
{
IsCpuEnabled = true,
IsGpuEnabled = true,
IsBatteryEnabled = true,
};
}
public void ReadSensors()
{
computer.Open();
computer.Accept(new UpdateVisitor());
cpuTemp = -1;
gpuTemp = -1;
batteryDischarge = -1;
batteryCharge = -1;
foreach (IHardware hardware in computer.Hardware)
{
//Debug.WriteLine("Hardware: {0}", hardware.Name);
//Debug.WriteLine("Hardware: {0}", hardware.HardwareType);
foreach (ISensor sensor in hardware.Sensors)
{
if (sensor.SensorType == SensorType.Temperature)
{
if (hardware.HardwareType.ToString().Contains("Cpu") && sensor.Name.Contains("Core"))
{
cpuTemp = sensor.Value;
//Debug.WriteLine("\tSensor: {0}, value: {1}", sensor.Name, sensor.Value);
}
if (hardware.HardwareType.ToString().Contains("Gpu") && sensor.Name.Contains("Core"))
{
gpuTemp = sensor.Value;
}
//Debug.WriteLine("\tSensor: {0}, value: {1}", sensor.Name, sensor.Value);
}
else if (sensor.SensorType == SensorType.Power)
{
if (sensor.Name.Contains("Discharge"))
{
batteryDischarge = sensor.Value;
}
if (sensor.Name.Contains("Charge"))
{
batteryCharge = sensor.Value;
}
}
}
}
}
public void StopReading()
{
computer.Close();
}
}
namespace GHelper
{
static class Program
@@ -499,7 +620,10 @@ namespace GHelper
public static AppConfig config;
public static SettingsForm settingsForm;
public static ToastForm toastForm;
public static Startup scheduler;
public static HardwareMonitor hwmonitor;
// The main entry point for the application
public static void Main()
@@ -534,10 +658,13 @@ namespace GHelper
settingsForm.SetStartupCheck(scheduler.IsScheduled());
bool isPlugged = (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
bool isPlugged = (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
settingsForm.AutoGPUMode(isPlugged ? 1 : 0);
settingsForm.AutoScreen(isPlugged ? 1 : 0);
hwmonitor = new HardwareMonitor();
IntPtr dummy = settingsForm.Handle;
Application.Run();
}
@@ -557,10 +684,12 @@ namespace GHelper
{
case 56: // Rog button
case 174: // FN+F5
settingsForm.BeginInvoke(delegate
{
settingsForm.CyclePerformanceMode();
});
return;
case 179: // FN+F4
settingsForm.BeginInvoke(delegate

View File

@@ -110,6 +110,16 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_speed_96 {
get {
object obj = ResourceManager.GetObject("icons8-speed-96", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -142,4 +142,7 @@
<data name="icons8-laptop-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-laptop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-speed-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-speed-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -1,4 +1,4 @@
# G14-Helper
# G-Helper (For G14, G15, ROG FLOW, and others)
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!.
@@ -29,6 +29,7 @@ Profiles are **same** as in Armory Crate, including default fan curves
5. FN+F5 an M4 (Rog) keys cycle through Performance modes
6. Screen resolution and display overdrive switching
7. CPU turbo boost switching
8. CPU & dGPU temperature monitoring in Celsius, battery charge / discharge rates in Watts
## Things still missing

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

78
Settings.Designer.cs generated
View File

@@ -31,8 +31,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsForm));
this.checkStartup = new System.Windows.Forms.CheckBox();
this.trackBattery = new System.Windows.Forms.TrackBar();
this.labelBattery = new System.Windows.Forms.Label();
this.labelBatteryLimit = new System.Windows.Forms.Label();
this.labelBatteryTitle = new System.Windows.Forms.Label();
this.pictureBattery = new System.Windows.Forms.PictureBox();
this.labelGPUFan = new System.Windows.Forms.Label();
this.tableGPU = new System.Windows.Forms.TableLayoutPanel();
@@ -62,6 +61,7 @@
this.comboKeyboard = new System.Windows.Forms.ComboBox();
this.buttonKeyboardColor = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.labelBattery = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.trackBattery)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBattery)).BeginInit();
this.tableGPU.SuspendLayout();
@@ -76,9 +76,8 @@
//
// checkStartup
//
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(31, 1022);
this.checkStartup.Location = new System.Drawing.Point(40, 1007);
this.checkStartup.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
this.checkStartup.Name = "checkStartup";
this.checkStartup.Size = new System.Drawing.Size(206, 36);
@@ -92,7 +91,7 @@
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(20, 919);
this.trackBattery.Location = new System.Drawing.Point(20, 908);
this.trackBattery.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
this.trackBattery.Maximum = 100;
this.trackBattery.Minimum = 50;
@@ -104,33 +103,22 @@
this.trackBattery.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
this.trackBattery.Value = 100;
//
// labelBattery
// labelBatteryTitle
//
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(77, 877);
this.labelBattery.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelBattery.Name = "labelBattery";
this.labelBattery.Size = new System.Drawing.Size(248, 32);
this.labelBattery.TabIndex = 4;
this.labelBattery.Text = "Battery Charge Limit";
//
// labelBatteryLimit
//
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(633, 874);
this.labelBatteryLimit.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelBatteryLimit.Name = "labelBatteryLimit";
this.labelBatteryLimit.Size = new System.Drawing.Size(73, 32);
this.labelBatteryLimit.TabIndex = 5;
this.labelBatteryLimit.Text = "100%";
this.labelBatteryTitle.AutoSize = true;
this.labelBatteryTitle.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelBatteryTitle.Location = new System.Drawing.Point(77, 871);
this.labelBatteryTitle.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelBatteryTitle.Name = "labelBatteryTitle";
this.labelBatteryTitle.Size = new System.Drawing.Size(248, 32);
this.labelBatteryTitle.TabIndex = 4;
this.labelBatteryTitle.Text = "Battery Charge Limit";
//
// pictureBattery
//
this.pictureBattery.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBattery.BackgroundImage")));
this.pictureBattery.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.pictureBattery.Location = new System.Drawing.Point(33, 875);
this.pictureBattery.Location = new System.Drawing.Point(33, 868);
this.pictureBattery.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
this.pictureBattery.Name = "pictureBattery";
this.pictureBattery.Size = new System.Drawing.Size(38, 38);
@@ -140,13 +128,13 @@
// labelGPUFan
//
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(546, 262);
this.labelGPUFan.Location = new System.Drawing.Point(425, 262);
this.labelGPUFan.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelGPUFan.Name = "labelGPUFan";
this.labelGPUFan.Size = new System.Drawing.Size(155, 32);
this.labelGPUFan.Size = new System.Drawing.Size(277, 32);
this.labelGPUFan.TabIndex = 8;
this.labelGPUFan.Text = "GPU Fan : 0%";
this.labelGPUFan.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// tableGPU
//
@@ -235,13 +223,13 @@
// 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(546, 38);
this.labelCPUFan.Location = new System.Drawing.Point(425, 38);
this.labelCPUFan.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelCPUFan.Name = "labelCPUFan";
this.labelCPUFan.Size = new System.Drawing.Size(154, 32);
this.labelCPUFan.Size = new System.Drawing.Size(277, 32);
this.labelCPUFan.TabIndex = 12;
this.labelCPUFan.Text = "CPU Fan : 0%";
this.labelCPUFan.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// tablePerf
//
@@ -346,7 +334,7 @@
//
// buttonQuit
//
this.buttonQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonQuit.BackColor = System.Drawing.SystemColors.ButtonFace;
this.buttonQuit.Location = new System.Drawing.Point(591, 1011);
this.buttonQuit.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
@@ -485,6 +473,7 @@
"Strobe",
"Rainbow"});
this.comboKeyboard.Location = new System.Drawing.Point(38, 778);
this.comboKeyboard.Margin = new System.Windows.Forms.Padding(0);
this.comboKeyboard.Name = "comboKeyboard";
this.comboKeyboard.Size = new System.Drawing.Size(200, 40);
this.comboKeyboard.TabIndex = 24;
@@ -494,7 +483,7 @@
//
this.buttonKeyboardColor.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.buttonKeyboardColor.FlatAppearance.BorderColor = System.Drawing.Color.Red;
this.buttonKeyboardColor.FlatAppearance.BorderSize = 4;
this.buttonKeyboardColor.FlatAppearance.BorderSize = 3;
this.buttonKeyboardColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonKeyboardColor.ForeColor = System.Drawing.SystemColors.ControlText;
this.buttonKeyboardColor.Location = new System.Drawing.Point(261, 773);
@@ -514,11 +503,23 @@
this.pictureBox2.TabIndex = 26;
this.pictureBox2.TabStop = false;
//
// labelBattery
//
this.labelBattery.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelBattery.Location = new System.Drawing.Point(491, 869);
this.labelBattery.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelBattery.Name = "labelBattery";
this.labelBattery.Size = new System.Drawing.Size(211, 32);
this.labelBattery.TabIndex = 27;
this.labelBattery.Text = " ";
this.labelBattery.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(744, 1085);
this.ClientSize = new System.Drawing.Size(744, 1093);
this.Controls.Add(this.labelBattery);
this.Controls.Add(this.buttonKeyboardColor);
this.Controls.Add(this.comboKeyboard);
this.Controls.Add(this.pictureBox1);
@@ -539,8 +540,7 @@
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.labelBatteryTitle);
this.Controls.Add(this.trackBattery);
this.Controls.Add(this.checkStartup);
this.Controls.Add(this.pictureBox2);
@@ -574,8 +574,7 @@
#endregion
private CheckBox checkStartup;
private TrackBar trackBattery;
private Label labelBattery;
private Label labelBatteryLimit;
private Label labelBatteryTitle;
private PictureBox pictureBattery;
private Label labelGPUFan;
private TableLayoutPanel tableGPU;
@@ -605,5 +604,6 @@
private ComboBox comboKeyboard;
private Button buttonKeyboardColor;
private PictureBox pictureBox2;
private Label labelBattery;
}
}

View File

@@ -1,11 +1,12 @@
using Microsoft.VisualBasic.ApplicationServices;
using System.Diagnostics;
using System.Management;
using System.Diagnostics;
using System.Timers;
using System.Windows.Forms;
using Windows.UI.Notifications;
using Microsoft.Toolkit.Uwp.Notifications;
namespace GHelper
{
public partial class SettingsForm : Form
{
@@ -88,7 +89,7 @@ namespace GHelper
Color color = Color.FromArgb(255, 255, 255);
if (mode == -1)
if (mode == -1)
mode = 0;
if (colorCode != -1)
@@ -99,7 +100,7 @@ namespace GHelper
SetAuraMode(mode, false);
Aura.Mode = mode;
}
@@ -114,9 +115,11 @@ namespace GHelper
buttonKeyboardColor.FlatAppearance.BorderColor = color;
}
public void SetAuraMode (int mode = 0, bool apply = true)
public void SetAuraMode(int mode = 0, bool apply = true)
{
//Debug.WriteLine(mode);
if (mode > 3) mode = 0;
if (Aura.Mode == mode) return; // same mode
@@ -124,13 +127,16 @@ namespace GHelper
Aura.Mode = mode;
Program.config.setConfig("aura_mode", mode);
comboKeyboard.SelectedValueChanged -= ComboKeyboard_SelectedValueChanged;
comboKeyboard.SelectedIndex = mode;
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
if (apply)
Aura.ApplyAura();
else
comboKeyboard.SelectedIndex = mode;
}
public void CycleAuraMode ()
public void CycleAuraMode()
{
SetAuraMode(Program.config.getConfig("aura_mode") + 1);
}
@@ -183,7 +189,8 @@ namespace GHelper
{
if (overdrive > 0)
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
} catch
}
catch
{
Debug.WriteLine("Screen Overdrive not supported");
}
@@ -226,7 +233,8 @@ namespace GHelper
try
{
overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
} catch
}
catch
{
Debug.WriteLine("Screen Overdrive not supported");
}
@@ -289,22 +297,54 @@ namespace GHelper
private static void SetTimer()
{
aTimer = new System.Timers.Timer(1000);
aTimer = new System.Timers.Timer(500);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = false;
}
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
private static void RefreshSensors()
{
var cpuFan = Math.Round(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan) / 0.6);
var gpuFan = Math.Round(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan) / 0.6);
string cpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan) / 0.6).ToString() + "%";
string gpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan) / 0.6) + "%";
string cpuTemp = "";
string gpuTemp = "";
string battery = "";
try
{
Program.hwmonitor.ReadSensors();
}
catch
{
Debug.WriteLine("Failed reading sensors");
}
if (Program.hwmonitor.cpuTemp > 0)
cpuTemp = ": " + Math.Round((decimal)Program.hwmonitor.cpuTemp).ToString() + "°C - ";
if (Program.hwmonitor.gpuTemp > 0)
gpuTemp = ": " + Math.Round((decimal)Program.hwmonitor.gpuTemp).ToString() + "°C - ";
if (Program.hwmonitor.batteryDischarge > 0)
battery = "Discharging: " + Math.Round((decimal)Program.hwmonitor.batteryDischarge, 1).ToString() + "W";
if (Program.hwmonitor.batteryCharge > 0)
battery = "Charging: " + Math.Round((decimal)Program.hwmonitor.batteryCharge, 1).ToString() + "W";
Program.settingsForm.BeginInvoke(delegate
{
Program.settingsForm.labelCPUFan.Text = "CPU Fan: " + cpuFan.ToString() + "%";
Program.settingsForm.labelGPUFan.Text = "GPU Fan: " + gpuFan.ToString() + "%";
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + cpuFan;
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
Program.settingsForm.labelBattery.Text = battery;
});
}
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
{
RefreshSensors();
aTimer.Interval = 2000;
}
private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
@@ -316,39 +356,52 @@ namespace GHelper
this.Left = Screen.FromControl(this).Bounds.Width - 10 - this.Width;
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
this.Activate();
aTimer.Interval = 500;
aTimer.Enabled = true;
}
else
{
aTimer.Enabled = false;
Program.hwmonitor.StopReading();
}
}
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
{
string perfName;
buttonSilent.FlatAppearance.BorderSize = buttonInactive;
buttonBalanced.FlatAppearance.BorderSize = buttonInactive;
buttonTurbo.FlatAppearance.BorderSize = buttonInactive;
string[] mode = new string[]{
"Balanced",
"Turbo",
"Silent"
};
switch (PerformanceMode)
{
case ASUSWmi.PerformanceSilent:
buttonSilent.FlatAppearance.BorderSize = buttonActive;
labelPerf.Text = "Performance Mode: Silent";
perfName = "Silent";
break;
case ASUSWmi.PerformanceTurbo:
buttonTurbo.FlatAppearance.BorderSize = buttonActive;
labelPerf.Text = "Performance Mode: Turbo";
perfName = "Turbo";
break;
default:
buttonBalanced.FlatAppearance.BorderSize = buttonActive;
labelPerf.Text = "Performance Mode: Balanced";
PerformanceMode = ASUSWmi.PerformanceBalanced;
perfName = "Balanced";
break;
}
string notifTitle = "Performance Mode Changed";
string notifBody = "Switched to: " + mode[PerformanceMode];
Program.config.setConfig("performance_mode", PerformanceMode);
try
{
@@ -358,14 +411,34 @@ namespace GHelper
labelPerf.Text = "Performance Mode: not supported";
}
if(notify)
sendNotification(notifTitle, notifBody);
}
public void CyclePerformanceMode()
{
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1);
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true);
}
public void sendNotification(string title, string message)
{
var content = new ToastContentBuilder()
.AddText(title)
.AddText(message)
.SetToastDuration(ToastDuration.Short)
.GetToastContent();
var notification = new ToastNotification(content.GetXml())
{
Priority = ToastNotificationPriority.High
};
ToastNotificationManagerCompat.CreateToastNotifier().Show(notification);
}
public void AutoScreen(int Plugged = 1)
{
int ScreenAuto = Program.config.getConfig("screen_auto");
@@ -376,6 +449,8 @@ namespace GHelper
else
SetScreen(60, 0);
InitScreen();
}
public void AutoGPUMode(int Plugged = 1)
@@ -396,18 +471,12 @@ namespace GHelper
if (eco == 1 && Plugged == 1) // Eco going Standard on plugged
{
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
GPUMode = ASUSWmi.GPUModeStandard;
VisualiseGPUMode(GPUMode);
Program.config.setConfig("gpu_mode", GPUMode);
InitGPUMode();
}
else if (eco == 0 && Plugged == 0) // Standard going Eco on plugged
{
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
GPUMode = ASUSWmi.GPUModeEco;
VisualiseGPUMode(GPUMode);
Program.config.setConfig("gpu_mode", GPUMode);
InitGPUMode();
}
}
@@ -584,12 +653,13 @@ namespace GHelper
if (limit < 50 || limit > 100) limit = 100;
labelBatteryLimit.Text = limit.ToString() + "%";
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
trackBattery.Value = limit;
try
{
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
} catch
}
catch
{
Debug.WriteLine("Can't set battery charge limit");
}

85
ToastForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,85 @@
namespace GHelper
{
partial class ToastForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureIcon = new System.Windows.Forms.PictureBox();
this.labelMode = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureIcon)).BeginInit();
this.SuspendLayout();
//
// pictureIcon
//
this.pictureIcon.BackgroundImage = global::GHelper.Properties.Resources.icons8_speed_96;
this.pictureIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.pictureIcon.Location = new System.Drawing.Point(21, 21);
this.pictureIcon.Name = "pictureIcon";
this.pictureIcon.Size = new System.Drawing.Size(82, 80);
this.pictureIcon.TabIndex = 0;
this.pictureIcon.TabStop = false;
//
// labelMode
//
this.labelMode.AutoSize = true;
this.labelMode.Font = new System.Drawing.Font("Segoe UI", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.labelMode.Location = new System.Drawing.Point(127, 32);
this.labelMode.Name = "labelMode";
this.labelMode.Size = new System.Drawing.Size(195, 59);
this.labelMode.TabIndex = 1;
this.labelMode.Text = "Balanced";
this.labelMode.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ToastForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.ClientSize = new System.Drawing.Size(356, 122);
this.Controls.Add(this.labelMode);
this.Controls.Add(this.pictureIcon);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MdiChildrenMinimizedAnchorBottom = false;
this.MinimizeBox = false;
this.Name = "ToastForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "ToastForm";
this.TopMost = true;
((System.ComponentModel.ISupportInitialize)(this.pictureIcon)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureIcon;
private Label labelMode;
}
}

68
ToastForm.cs Normal file
View File

@@ -0,0 +1,68 @@
using System.Runtime.InteropServices;
namespace GHelper
{
public partial class ToastForm : Form
{
private System.Windows.Forms.Timer timer = default!;
private const int SW_SHOWNOACTIVATE = 4;
private const int HWND_TOPMOST = -1;
private const uint SWP_NOACTIVATE = 0x0010;
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
static extern bool SetWindowPos(
int hWnd, // Window handle
int hWndInsertAfter, // Placement-order handle
int X, // Horizontal position
int Y, // Vertical position
int cx, // Width
int cy, // Height
uint uFlags); // Window positioning flags
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void ShowInactiveTopmost(Form frm)
{
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
frm.Left, frm.Top, frm.Width, frm.Height,
SWP_NOACTIVATE);
}
public ToastForm()
{
InitializeComponent();
}
public void RunToast(string text)
{
Top = Screen.FromControl(this).WorkingArea.Height - this.Height - 100;
Left = (Screen.FromControl(this).Bounds.Width - this.Width) / 2;
ShowInactiveTopmost(this);
labelMode.Text = text;
timer = new System.Windows.Forms.Timer();
timer.Tick += new EventHandler(timer_Tick);
timer.Enabled = true;
timer.Interval = 1000;
timer.Start();
}
private void ToastForm_Show(object? sender, EventArgs e)
{
}
private void timer_Tick(object sender, EventArgs e)
{
timer.Stop();
Close();
}
}
}

60
ToastForm.resx Normal file
View File

@@ -0,0 +1,60 @@
<root>
<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>
</root>

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB