mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bb5e41a5d | ||
|
|
bc965c003d | ||
|
|
a6cfc91de2 | ||
|
|
9ca6ec657f |
@@ -16,7 +16,7 @@
|
|||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>0.26</AssemblyVersion>
|
<AssemblyVersion>0.27</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using static Tools.ScreenInterrogatory;
|
using static Tools.ScreenInterrogatory;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Tools
|
namespace Tools
|
||||||
{
|
{
|
||||||
@@ -545,22 +546,19 @@ public class NativeMethods
|
|||||||
|
|
||||||
foreach (var device in devices)
|
foreach (var device in devices)
|
||||||
{
|
{
|
||||||
if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL)
|
if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL ||
|
||||||
|
device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED)
|
||||||
{
|
{
|
||||||
displayNum = count;
|
displayNum = count;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
//Debug.WriteLine(device.outputTechnology);
|
//Logger.WriteLine(device.outputTechnology.ToString());
|
||||||
//Debug.WriteLine(device.monitorFriendlyDeviceName);
|
//Logger.WriteLine(device.monitorFriendlyDeviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
var screens = Screen.AllScreens;
|
var screens = Screen.AllScreens;
|
||||||
|
|
||||||
if (screens.Length != count)
|
if (screens.Length != count) return null;
|
||||||
{
|
|
||||||
Debug.WriteLine("Mismatch between enumerated and available screens");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
foreach (var screen in screens)
|
foreach (var screen in screens)
|
||||||
@@ -569,13 +567,15 @@ public class NativeMethods
|
|||||||
{
|
{
|
||||||
laptopScreen = screen.DeviceName;
|
laptopScreen = screen.DeviceName;
|
||||||
}
|
}
|
||||||
//Debug.WriteLine(screen.DeviceName);
|
//Logger.WriteLine(screen.DeviceName);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Can't find internal screen");
|
Logger.WriteLine(ex.ToString());
|
||||||
|
Logger.WriteLine("Can't detect internal screen");
|
||||||
|
//laptopScreen = Screen.PrimaryScreen.DeviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
Program.cs
32
Program.cs
@@ -6,20 +6,36 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
public static class Logger
|
public static class Logger
|
||||||
{
|
{
|
||||||
|
static string appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||||
|
static string logFile = appPath + "\\log.txt";
|
||||||
|
|
||||||
public static void WriteLine(string logMessage)
|
public static void WriteLine(string logMessage)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(logMessage);
|
Debug.WriteLine(logMessage);
|
||||||
|
|
||||||
var appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
|
||||||
var logFile = appPath + "\\log.txt";
|
|
||||||
|
|
||||||
if (!Directory.Exists(appPath)) Directory.CreateDirectory(appPath);
|
if (!Directory.Exists(appPath)) Directory.CreateDirectory(appPath);
|
||||||
|
|
||||||
using (StreamWriter w = File.AppendText(logFile))
|
try
|
||||||
{
|
{
|
||||||
w.WriteLine($"{DateTime.Now}: {logMessage}");
|
using (StreamWriter w = File.AppendText(logFile))
|
||||||
|
{
|
||||||
|
w.WriteLine($"{DateTime.Now}: {logMessage}");
|
||||||
|
w.Close();
|
||||||
|
}
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new Random().Next(100) == 1) Cleanup();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Cleanup()
|
||||||
|
{
|
||||||
|
var file = File.ReadAllLines(logFile);
|
||||||
|
int skip = Math.Max(0, file.Count() - 500);
|
||||||
|
File.WriteAllLines(logFile,file.Skip(skip).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -204,7 +220,9 @@ namespace GHelper
|
|||||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||||
|
|
||||||
settingsForm.AutoPerformance(isPlugged);
|
settingsForm.AutoPerformance(isPlugged);
|
||||||
settingsForm.AutoGPUMode(isPlugged);
|
|
||||||
|
bool switched = settingsForm.AutoGPUMode(isPlugged);
|
||||||
|
if (!switched) settingsForm.AutoScreen(isPlugged);
|
||||||
|
|
||||||
settingsForm.SetMatrix(isPlugged);
|
settingsForm.SetMatrix(isPlugged);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# G-Helper / GHelper for Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and other models
|
# G-Helper / GHelper
|
||||||
|
|
||||||
|
## For Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and other models
|
||||||
|
|
||||||
A small utility that allows you do almost everyting you could do with Armory Crate but without extra bloat and unnecessary services.
|
A small utility that allows you do almost everyting you could do with Armory Crate but without extra bloat and unnecessary services.
|
||||||
|
|
||||||
|
|||||||
24
Settings.Designer.cs
generated
24
Settings.Designer.cs
generated
@@ -193,7 +193,7 @@
|
|||||||
//
|
//
|
||||||
pictureMatrix.BackgroundImage = Properties.Resources.icons8_matrix_desktop_48;
|
pictureMatrix.BackgroundImage = Properties.Resources.icons8_matrix_desktop_48;
|
||||||
pictureMatrix.BackgroundImageLayout = ImageLayout.Zoom;
|
pictureMatrix.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
pictureMatrix.Location = new Point(29, 10);
|
pictureMatrix.Location = new Point(25, 10);
|
||||||
pictureMatrix.Margin = new Padding(4, 2, 4, 2);
|
pictureMatrix.Margin = new Padding(4, 2, 4, 2);
|
||||||
pictureMatrix.Name = "pictureMatrix";
|
pictureMatrix.Name = "pictureMatrix";
|
||||||
pictureMatrix.Size = new Size(36, 36);
|
pictureMatrix.Size = new Size(36, 36);
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
//
|
//
|
||||||
labelMatrix.AutoSize = true;
|
labelMatrix.AutoSize = true;
|
||||||
labelMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
labelMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
labelMatrix.Location = new Point(68, 12);
|
labelMatrix.Location = new Point(64, 12);
|
||||||
labelMatrix.Margin = new Padding(4, 0, 4, 0);
|
labelMatrix.Margin = new Padding(4, 0, 4, 0);
|
||||||
labelMatrix.Name = "labelMatrix";
|
labelMatrix.Name = "labelMatrix";
|
||||||
labelMatrix.Size = new Size(170, 32);
|
labelMatrix.Size = new Size(170, 32);
|
||||||
@@ -252,7 +252,7 @@
|
|||||||
//
|
//
|
||||||
pictureBattery.BackgroundImage = (Image)resources.GetObject("pictureBattery.BackgroundImage");
|
pictureBattery.BackgroundImage = (Image)resources.GetObject("pictureBattery.BackgroundImage");
|
||||||
pictureBattery.BackgroundImageLayout = ImageLayout.Zoom;
|
pictureBattery.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
pictureBattery.Location = new Point(29, 10);
|
pictureBattery.Location = new Point(25, 10);
|
||||||
pictureBattery.Margin = new Padding(4, 2, 4, 2);
|
pictureBattery.Margin = new Padding(4, 2, 4, 2);
|
||||||
pictureBattery.Name = "pictureBattery";
|
pictureBattery.Name = "pictureBattery";
|
||||||
pictureBattery.Size = new Size(36, 38);
|
pictureBattery.Size = new Size(36, 38);
|
||||||
@@ -262,7 +262,7 @@
|
|||||||
// labelBatteryTitle
|
// labelBatteryTitle
|
||||||
//
|
//
|
||||||
labelBatteryTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
labelBatteryTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
labelBatteryTitle.Location = new Point(70, 12);
|
labelBatteryTitle.Location = new Point(66, 12);
|
||||||
labelBatteryTitle.Margin = new Padding(4, 0, 4, 0);
|
labelBatteryTitle.Margin = new Padding(4, 0, 4, 0);
|
||||||
labelBatteryTitle.Name = "labelBatteryTitle";
|
labelBatteryTitle.Name = "labelBatteryTitle";
|
||||||
labelBatteryTitle.Size = new Size(408, 36);
|
labelBatteryTitle.Size = new Size(408, 36);
|
||||||
@@ -351,7 +351,7 @@
|
|||||||
picturePerf.BackgroundImage = (Image)resources.GetObject("picturePerf.BackgroundImage");
|
picturePerf.BackgroundImage = (Image)resources.GetObject("picturePerf.BackgroundImage");
|
||||||
picturePerf.BackgroundImageLayout = ImageLayout.Zoom;
|
picturePerf.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
picturePerf.InitialImage = null;
|
picturePerf.InitialImage = null;
|
||||||
picturePerf.Location = new Point(29, 10);
|
picturePerf.Location = new Point(25, 10);
|
||||||
picturePerf.Margin = new Padding(4, 2, 4, 2);
|
picturePerf.Margin = new Padding(4, 2, 4, 2);
|
||||||
picturePerf.Name = "picturePerf";
|
picturePerf.Name = "picturePerf";
|
||||||
picturePerf.Size = new Size(36, 38);
|
picturePerf.Size = new Size(36, 38);
|
||||||
@@ -362,7 +362,7 @@
|
|||||||
//
|
//
|
||||||
labelPerf.AutoSize = true;
|
labelPerf.AutoSize = true;
|
||||||
labelPerf.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
labelPerf.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
labelPerf.Location = new Point(68, 12);
|
labelPerf.Location = new Point(64, 12);
|
||||||
labelPerf.Margin = new Padding(4, 0, 4, 0);
|
labelPerf.Margin = new Padding(4, 0, 4, 0);
|
||||||
labelPerf.Name = "labelPerf";
|
labelPerf.Name = "labelPerf";
|
||||||
labelPerf.Size = new Size(234, 32);
|
labelPerf.Size = new Size(234, 32);
|
||||||
@@ -476,7 +476,7 @@
|
|||||||
//
|
//
|
||||||
pictureGPU.BackgroundImage = (Image)resources.GetObject("pictureGPU.BackgroundImage");
|
pictureGPU.BackgroundImage = (Image)resources.GetObject("pictureGPU.BackgroundImage");
|
||||||
pictureGPU.BackgroundImageLayout = ImageLayout.Zoom;
|
pictureGPU.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
pictureGPU.Location = new Point(29, 10);
|
pictureGPU.Location = new Point(25, 10);
|
||||||
pictureGPU.Margin = new Padding(4, 2, 4, 2);
|
pictureGPU.Margin = new Padding(4, 2, 4, 2);
|
||||||
pictureGPU.Name = "pictureGPU";
|
pictureGPU.Name = "pictureGPU";
|
||||||
pictureGPU.Size = new Size(36, 38);
|
pictureGPU.Size = new Size(36, 38);
|
||||||
@@ -487,7 +487,7 @@
|
|||||||
//
|
//
|
||||||
labelGPU.AutoSize = true;
|
labelGPU.AutoSize = true;
|
||||||
labelGPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
labelGPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
labelGPU.Location = new Point(70, 12);
|
labelGPU.Location = new Point(66, 12);
|
||||||
labelGPU.Margin = new Padding(4, 0, 4, 0);
|
labelGPU.Margin = new Padding(4, 0, 4, 0);
|
||||||
labelGPU.Name = "labelGPU";
|
labelGPU.Name = "labelGPU";
|
||||||
labelGPU.Size = new Size(136, 32);
|
labelGPU.Size = new Size(136, 32);
|
||||||
@@ -648,7 +648,7 @@
|
|||||||
//
|
//
|
||||||
pictureScreen.BackgroundImage = (Image)resources.GetObject("pictureScreen.BackgroundImage");
|
pictureScreen.BackgroundImage = (Image)resources.GetObject("pictureScreen.BackgroundImage");
|
||||||
pictureScreen.BackgroundImageLayout = ImageLayout.Zoom;
|
pictureScreen.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
pictureScreen.Location = new Point(29, 8);
|
pictureScreen.Location = new Point(25, 8);
|
||||||
pictureScreen.Margin = new Padding(4, 2, 4, 2);
|
pictureScreen.Margin = new Padding(4, 2, 4, 2);
|
||||||
pictureScreen.Name = "pictureScreen";
|
pictureScreen.Name = "pictureScreen";
|
||||||
pictureScreen.Size = new Size(36, 38);
|
pictureScreen.Size = new Size(36, 38);
|
||||||
@@ -659,7 +659,7 @@
|
|||||||
//
|
//
|
||||||
labelSreen.AutoSize = true;
|
labelSreen.AutoSize = true;
|
||||||
labelSreen.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
labelSreen.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
labelSreen.Location = new Point(72, 10);
|
labelSreen.Location = new Point(68, 10);
|
||||||
labelSreen.Margin = new Padding(4, 0, 4, 0);
|
labelSreen.Margin = new Padding(4, 0, 4, 0);
|
||||||
labelSreen.Name = "labelSreen";
|
labelSreen.Name = "labelSreen";
|
||||||
labelSreen.Size = new Size(176, 32);
|
labelSreen.Size = new Size(176, 32);
|
||||||
@@ -774,7 +774,7 @@
|
|||||||
//
|
//
|
||||||
pictureKeyboard.BackgroundImage = Properties.Resources.icons8_keyboard_48;
|
pictureKeyboard.BackgroundImage = Properties.Resources.icons8_keyboard_48;
|
||||||
pictureKeyboard.BackgroundImageLayout = ImageLayout.Zoom;
|
pictureKeyboard.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
pictureKeyboard.Location = new Point(29, 16);
|
pictureKeyboard.Location = new Point(25, 16);
|
||||||
pictureKeyboard.Margin = new Padding(4, 2, 4, 2);
|
pictureKeyboard.Margin = new Padding(4, 2, 4, 2);
|
||||||
pictureKeyboard.Name = "pictureKeyboard";
|
pictureKeyboard.Name = "pictureKeyboard";
|
||||||
pictureKeyboard.Size = new Size(36, 36);
|
pictureKeyboard.Size = new Size(36, 36);
|
||||||
@@ -785,7 +785,7 @@
|
|||||||
//
|
//
|
||||||
label1.AutoSize = true;
|
label1.AutoSize = true;
|
||||||
label1.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
label1.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
label1.Location = new Point(72, 16);
|
label1.Location = new Point(68, 16);
|
||||||
label1.Margin = new Padding(4, 0, 4, 0);
|
label1.Margin = new Padding(4, 0, 4, 0);
|
||||||
label1.Name = "label1";
|
label1.Name = "label1";
|
||||||
label1.Size = new Size(210, 32);
|
label1.Size = new Size(210, 32);
|
||||||
|
|||||||
17
Settings.cs
17
Settings.cs
@@ -858,33 +858,33 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public bool AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||||
{
|
{
|
||||||
|
|
||||||
int GpuAuto = Program.config.getConfig("gpu_auto");
|
int GpuAuto = Program.config.getConfig("gpu_auto");
|
||||||
if (GpuAuto != 1) return;
|
if (GpuAuto != 1) return false;
|
||||||
|
|
||||||
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
|
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
|
||||||
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
|
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
|
||||||
|
|
||||||
if (mux == 0) // GPU in Ultimate, ignore
|
if (mux == 0) // GPU in Ultimate, ignore
|
||||||
return;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
|
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
|
||||||
{
|
{
|
||||||
SetEcoGPU(0);
|
SetEcoGPU(0);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
|
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
|
||||||
{
|
{
|
||||||
SetEcoGPU(1);
|
SetEcoGPU(1);
|
||||||
}
|
return true;
|
||||||
else
|
|
||||||
{
|
|
||||||
AutoScreen(Plugged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int InitGPUMode()
|
public int InitGPUMode()
|
||||||
@@ -988,7 +988,8 @@ namespace GHelper
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed)
|
||||||
|
{
|
||||||
Program.config.setConfig("gpu_mode", GPUMode);
|
Program.config.setConfig("gpu_mode", GPUMode);
|
||||||
|
|
||||||
HardwareMonitor.RecreateGpuTemperatureProviderWithRetry();
|
HardwareMonitor.RecreateGpuTemperatureProviderWithRetry();
|
||||||
|
|||||||
Reference in New Issue
Block a user