mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
10 Commits
v0.9
...
notificati
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc1f3ab530 | ||
|
|
3cd62bc9e1 | ||
|
|
16f6f3f934 | ||
|
|
1f4afedc1d | ||
|
|
c705ce2b5b | ||
|
|
75942ebdb2 | ||
|
|
6d142213c8 | ||
|
|
bfcb97b158 | ||
|
|
f97765c5c2 | ||
|
|
19a8b0dc22 |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net7.0-windows8.0</TargetFramework>
|
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>True</UseWindowsForms>
|
<UseWindowsForms>True</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="hidlibrary" Version="3.3.40" />
|
<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="LibreHardwareMonitorLib" Version="0.9.1" />
|
||||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
<PackageReference Include="System.Management" Version="7.0.0" />
|
||||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
using HidLibrary;
|
||||||
|
using LibreHardwareMonitor.Hardware;
|
||||||
using Microsoft.Win32.TaskScheduler;
|
using Microsoft.Win32.TaskScheduler;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using HidLibrary;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using LibreHardwareMonitor.Hardware;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
public class ASUSWmi
|
public class ASUSWmi
|
||||||
{
|
{
|
||||||
@@ -232,7 +231,7 @@ public class NativeMethods
|
|||||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
|
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
|
||||||
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
|
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
|
||||||
int AcValueIndex);
|
int AcValueIndex);
|
||||||
|
|
||||||
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
||||||
static extern UInt32 PowerReadACValueIndex(IntPtr RootPowerKey,
|
static extern UInt32 PowerReadACValueIndex(IntPtr RootPowerKey,
|
||||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
|
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
|
||||||
@@ -550,7 +549,7 @@ public class HardwareMonitor
|
|||||||
|
|
||||||
public void ReadSensors()
|
public void ReadSensors()
|
||||||
{
|
{
|
||||||
|
|
||||||
computer.Open();
|
computer.Open();
|
||||||
computer.Accept(new UpdateVisitor());
|
computer.Accept(new UpdateVisitor());
|
||||||
|
|
||||||
|
|||||||
@@ -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!.
|
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
|
5. FN+F5 an M4 (Rog) keys cycle through Performance modes
|
||||||
6. Screen resolution and display overdrive switching
|
6. Screen resolution and display overdrive switching
|
||||||
7. CPU turbo boost switching
|
7. CPU turbo boost switching
|
||||||
|
8. CPU & dGPU temperature monitoring in Celsius, battery charge / discharge rates in Watts
|
||||||
|
|
||||||
## Things still missing
|
## Things still missing
|
||||||
|
|
||||||
|
|||||||
5
Settings.Designer.cs
generated
5
Settings.Designer.cs
generated
@@ -473,6 +473,7 @@
|
|||||||
"Strobe",
|
"Strobe",
|
||||||
"Rainbow"});
|
"Rainbow"});
|
||||||
this.comboKeyboard.Location = new System.Drawing.Point(38, 778);
|
this.comboKeyboard.Location = new System.Drawing.Point(38, 778);
|
||||||
|
this.comboKeyboard.Margin = new System.Windows.Forms.Padding(0);
|
||||||
this.comboKeyboard.Name = "comboKeyboard";
|
this.comboKeyboard.Name = "comboKeyboard";
|
||||||
this.comboKeyboard.Size = new System.Drawing.Size(200, 40);
|
this.comboKeyboard.Size = new System.Drawing.Size(200, 40);
|
||||||
this.comboKeyboard.TabIndex = 24;
|
this.comboKeyboard.TabIndex = 24;
|
||||||
@@ -482,7 +483,7 @@
|
|||||||
//
|
//
|
||||||
this.buttonKeyboardColor.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
this.buttonKeyboardColor.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||||
this.buttonKeyboardColor.FlatAppearance.BorderColor = System.Drawing.Color.Red;
|
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.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
this.buttonKeyboardColor.ForeColor = System.Drawing.SystemColors.ControlText;
|
this.buttonKeyboardColor.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||||
this.buttonKeyboardColor.Location = new System.Drawing.Point(261, 773);
|
this.buttonKeyboardColor.Location = new System.Drawing.Point(261, 773);
|
||||||
@@ -517,7 +518,7 @@
|
|||||||
//
|
//
|
||||||
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(744, 1085);
|
this.ClientSize = new System.Drawing.Size(744, 1093);
|
||||||
this.Controls.Add(this.labelBattery);
|
this.Controls.Add(this.labelBattery);
|
||||||
this.Controls.Add(this.buttonKeyboardColor);
|
this.Controls.Add(this.buttonKeyboardColor);
|
||||||
this.Controls.Add(this.comboKeyboard);
|
this.Controls.Add(this.comboKeyboard);
|
||||||
|
|||||||
51
Settings.cs
51
Settings.cs
@@ -1,5 +1,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Windows.UI.Notifications;
|
||||||
|
using Microsoft.Toolkit.Uwp.Notifications;
|
||||||
|
|
||||||
namespace GHelper
|
namespace GHelper
|
||||||
{
|
{
|
||||||
@@ -294,12 +297,13 @@ namespace GHelper
|
|||||||
|
|
||||||
private static void SetTimer()
|
private static void SetTimer()
|
||||||
{
|
{
|
||||||
aTimer = new System.Timers.Timer(1000);
|
aTimer = new System.Timers.Timer(500);
|
||||||
aTimer.Elapsed += OnTimedEvent;
|
aTimer.Elapsed += OnTimedEvent;
|
||||||
aTimer.AutoReset = true;
|
aTimer.AutoReset = true;
|
||||||
|
aTimer.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
|
private static void RefreshSensors()
|
||||||
{
|
{
|
||||||
string cpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan) / 0.6).ToString() + "%";
|
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 gpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan) / 0.6) + "%";
|
||||||
@@ -311,7 +315,8 @@ namespace GHelper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Program.hwmonitor.ReadSensors();
|
Program.hwmonitor.ReadSensors();
|
||||||
} catch
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Failed reading sensors");
|
Debug.WriteLine("Failed reading sensors");
|
||||||
}
|
}
|
||||||
@@ -334,7 +339,12 @@ namespace GHelper
|
|||||||
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
|
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
|
||||||
Program.settingsForm.labelBattery.Text = battery;
|
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)
|
private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
|
||||||
@@ -346,6 +356,8 @@ namespace GHelper
|
|||||||
this.Left = Screen.FromControl(this).Bounds.Width - 10 - this.Width;
|
this.Left = Screen.FromControl(this).Bounds.Width - 10 - this.Width;
|
||||||
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
|
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
|
||||||
this.Activate();
|
this.Activate();
|
||||||
|
|
||||||
|
aTimer.Interval = 500;
|
||||||
aTimer.Enabled = true;
|
aTimer.Enabled = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -365,6 +377,12 @@ namespace GHelper
|
|||||||
buttonBalanced.FlatAppearance.BorderSize = buttonInactive;
|
buttonBalanced.FlatAppearance.BorderSize = buttonInactive;
|
||||||
buttonTurbo.FlatAppearance.BorderSize = buttonInactive;
|
buttonTurbo.FlatAppearance.BorderSize = buttonInactive;
|
||||||
|
|
||||||
|
string[] mode = new string[]{
|
||||||
|
"Balanced",
|
||||||
|
"Turbo",
|
||||||
|
"Silent"
|
||||||
|
};
|
||||||
|
|
||||||
switch (PerformanceMode)
|
switch (PerformanceMode)
|
||||||
{
|
{
|
||||||
case ASUSWmi.PerformanceSilent:
|
case ASUSWmi.PerformanceSilent:
|
||||||
@@ -382,24 +400,45 @@ namespace GHelper
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string notifTitle = "Performance Mode Changed";
|
||||||
|
string notifBody = "Switched to: " + mode[PerformanceMode];
|
||||||
Program.config.setConfig("performance_mode", PerformanceMode);
|
Program.config.setConfig("performance_mode", PerformanceMode);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||||
}
|
} catch
|
||||||
catch
|
|
||||||
{
|
{
|
||||||
labelPerf.Text = "Performance Mode: not supported";
|
labelPerf.Text = "Performance Mode: not supported";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(notify)
|
||||||
|
sendNotification(notifTitle, notifBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void CyclePerformanceMode()
|
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)
|
public void AutoScreen(int Plugged = 1)
|
||||||
{
|
{
|
||||||
int ScreenAuto = Program.config.getConfig("screen_auto");
|
int ScreenAuto = Program.config.getConfig("screen_auto");
|
||||||
|
|||||||
Reference in New Issue
Block a user