Compare commits

...

23 Commits

Author SHA1 Message Date
seerge
52c6615ebc Merge branch 'main' of https://github.com/seerge/g14-helper 2023-02-14 23:03:08 +01:00
seerge
23405632ad Separate package with ps1 script only 2023-02-14 23:03:02 +01:00
seerge
52e2b8b31c Update README.md 2023-02-14 12:46:46 +01:00
seerge
b25eb63116 Update README.md 2023-02-14 12:21:34 +01:00
seerge
4bfbdd04cb Update README.md 2023-02-14 12:17:41 +01:00
seerge
efe887fbc3 Update README.md 2023-02-14 12:11:15 +01:00
seerge
5919bfd71e Update README.md 2023-02-14 12:07:29 +01:00
seerge
c9e25b6358 Minor tweaks and cleanup 2023-02-14 11:47:17 +01:00
seerge
fb4a0cf3db - 2023-02-14 00:02:17 +01:00
seerge
b534becbf5 = 2023-02-14 00:02:06 +01:00
seerge
99316da55e Added battery charge limit control 2023-02-13 23:30:03 +01:00
seerge
cf92e04501 2023-02-13 19:33:50 +01:00
seerge
39514d89f6 - 2023-02-13 19:31:18 +01:00
seerge
293ab6f35d Workflow adjustments 2023-02-13 19:27:39 +01:00
seerge
f2967fcc79 - 2023-02-13 19:23:29 +01:00
seerge
e060feaf09 Workflow adjustments 2023-02-13 19:19:45 +01:00
seerge
178f61a98d Workflow adjustments 2023-02-13 19:16:20 +01:00
seerge
79b8d6fa14 - 2023-02-13 19:11:49 +01:00
seerge
007f6ef1a3 Minor fixes 2023-02-13 19:07:07 +01:00
seerge
1637f36d1d Minor fixes 2023-02-13 19:05:48 +01:00
seerge
0f3f54c50a Merge branch 'main' of https://github.com/seerge/g14-helper 2023-02-13 19:02:17 +01:00
seerge
aff667345d Minor fixes 2023-02-13 19:02:10 +01:00
seerge
b14ee181f9 Create main.yml 2023-02-13 19:01:31 +01:00
13 changed files with 208 additions and 74 deletions

33
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Main
on:
push:
tags:
- "v*.*"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: |
mkdir release
cp *.cmd ./release
cp *.lnk ./release
cp ghelper.ps1 ./release
zip -r g14-helper-script.zip ./release
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
g14-helper-script.zip
g14-helper.exe

BIN
G14-Helper.lnk Normal file

Binary file not shown.

View File

@@ -1,26 +1,54 @@
# G14-Helper # G14-Helper
Designed for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models. 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 small windows system tray utility that allows you to switch between 3 main GPU modes (mirroring ones from ASUS Armory Crate). Uses ASUS WMI commands to do switching and doens't require Armory Crate to be isntalled at all. Requires Administrator priveledges on Windows to run. 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!.
![Screenshot](https://github.com/seerge/g14-helper/blob/main/g14-helper.png) ## 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 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 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 3. Ultimate mode: iGPU and dGPU enabled, but dGPU drives built in display
##UPDATE: February 12, 2023 ## Extras
1. Added switching of **Performance profiles (including default fan curves)** is also available! switching happens via same ASUS WMI low level commands. Profiles are same as in Armory Crate - Silent, Balanced and Turbo. 1. **Maximum battery charge rate** limit (60% / 80% / 100%) to preserve your battery
2. CPU and GPU relative fan speed monitoring
3. Laptop screen refresh adjustments for power saving (60hz) and gaming (120hz)
4. Laptop screen panel overdrive switch
5. Start with windows (optional)
2. App now monitors (once every 3 seconds) fan speeds and shows them in the menu
3. App will save settings and write a basic log of it's actions to APPDATA\LOCAL directory ## How to install
4. App will reapply Panel Overdrive and Performance mode on each start (based on last setting from config) 1. Download latest release from https://github.com/seerge/g14-helper/releases
2. Unzip to a folder of your choice
3. Run **g14-helper.exe**
_App is written in Powershell and wrapped into executable with https://github.com/MScholtes/PS2EXE .
If you don't trust exe - you can always run ghelper.ps1 script by yourself directly._
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.
![Screenshot](https://github.com/seerge/g14-helper/blob/main/g14-helper.png)
Settings and basic log are located in APPDATA\LOCAL
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
Extra: **autostart.ps1** script to schedule autostart of the app (with admin privileges) on every user logon for convenience. Later will be integrated into main app.
-------- --------
![Ultimate Mode](https://github.com/seerge/g14-helper/blob/main/ultimate.png) ![Ultimate Mode](https://github.com/seerge/g14-helper/blob/main/ultimate.png)

View File

@@ -1,18 +0,0 @@
$taskName = "G14Helper"
$task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if ($task -ne $null)
{
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false
}
$scriptDir = Split-Path $PSCommandPath -Parent
# TODO: EDIT THIS STUFF AS NEEDED...
$action = New-ScheduledTaskAction -Execute "$scriptDir\g14-helper.exe"
$trigger = New-ScheduledTaskTrigger -AtLogon
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$definition = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings -Description "Run $($taskName) at Logon"
Register-ScheduledTask -TaskName $taskName -InputObject $definition

13
events.ps1 Normal file
View File

@@ -0,0 +1,13 @@
Get-EventSubscriber | Unregister-Event
$ProcessAsusWmiEvent = {
$event_id = $Event.SourceEventArgs.NewEvent.EventID
Write-Host $event_id
}
Register-CimIndicationEvent -Namespace root\wmi -query "Select * From AsusAtkWmiEvent" ` -sourceIdentifier "GHAsus" ` -action $ProcessAsusWmiEvent
while (1) {
}

1
g14-helper.cmd Normal file
View File

@@ -0,0 +1 @@
powershell -WindowStyle hidden -file ghelper.ps1

Binary file not shown.

View File

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

View File

@@ -1,27 +1,40 @@
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | out-null # Self-elevate the script
[System.Reflection.Assembly]::LoadWithPartialName('presentationframework') | out-null if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') | out-null if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
[System.Reflection.Assembly]::LoadWithPartialName('WindowsFormsIntegration') | out-null $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine -WindowStyle Hidden
Exit
Function Get-PSScriptPath {
if ([System.IO.Path]::GetExtension($PSCommandPath) -eq '.ps1') {
$psScriptPath = $PSCommandPath
} else {
$psScriptPath = [System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName
} }
return $psScriptPath
} }
# DPI Awareness
Add-Type -TypeDefinition @'
using System.Runtime.InteropServices;
public class ProcessDPI {
[DllImport("user32.dll", SetLastError=true)]
public static extern bool SetProcessDPIAware();
}
'@
$null = [ProcessDPI]::SetProcessDPIAware()
[System.Windows.Forms.Application]::EnableVisualStyles()
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName WindowsFormsIntegration
function SetAutostart () { function SetAutostart () {
$taskName = "G14Helper" $taskName = "G14Helper"
$task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue $task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if ($task -ne $null) {return } if ($null -ne $task) {return }
$scriptDir = Get-PSScriptPath if ([System.IO.Path]::GetExtension($PSCommandPath) -eq '.ps1') {
$action = New-ScheduledTaskAction -Execute "powershell" -Argument "-WindowStyle Hidden -File $PSCommandPath"
} else {
$psScriptPath = [System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName
$action = New-ScheduledTaskAction -Execute $psScriptPath
}
$action = New-ScheduledTaskAction -Execute $scriptDir
$trigger = New-ScheduledTaskTrigger -AtLogon $trigger = New-ScheduledTaskTrigger -AtLogon
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
@@ -34,7 +47,7 @@ function SetAutostart () {
function CheckAutostart () { function CheckAutostart () {
$task = Get-ScheduledTask -TaskName "G14Helper" -ErrorAction SilentlyContinue $task = Get-ScheduledTask -TaskName "G14Helper" -ErrorAction SilentlyContinue
$Menu_Autostart.Checked = ($task -ne $null) $Menu_Autostart.Checked = ($null -ne $task)
} }
function DisableAutostart () { function DisableAutostart () {
@@ -190,8 +203,8 @@ $icon_ultimate = [Drawing.Icon][IO.MemoryStream][Convert]::FromBase64String("AAA
# Init Config and Log # Init Config and Log
$ghelper_app_path = "$($env:LOCALAPPDATA)\GHelper" $ghelper_app_path = "$($env:LOCALAPPDATA)\GHelper"
$ghelper_config_path = "$($env:LOCALAPPDATA)\GHelper\config.json" $ghelper_config_path = "$ghelper_app_path\config.json"
$ghelper_log_path = "$($env:LOCALAPPDATA)\GHelper\log.txt" $ghelper_log_path = "$ghelper_app_path\log.txt"
New-Item -ItemType Directory -Force -Path $ghelper_app_path New-Item -ItemType Directory -Force -Path $ghelper_app_path
@@ -203,6 +216,7 @@ $Main_Tool_Icon.Visible = $true
$Menu_Perf_Title = New-Object System.Windows.Forms.MenuItem("Mode") $Menu_Perf_Title = New-Object System.Windows.Forms.MenuItem("Mode")
$Menu_Perf_Title.Enabled = $false $Menu_Perf_Title.Enabled = $false
$Menu_Perf_Silent = New-Object System.Windows.Forms.MenuItem("Silent") $Menu_Perf_Silent = New-Object System.Windows.Forms.MenuItem("Silent")
$Menu_Perf_Balanced = New-Object System.Windows.Forms.MenuItem("Balanced") $Menu_Perf_Balanced = New-Object System.Windows.Forms.MenuItem("Balanced")
$Menu_Perf_Turbo = New-Object System.Windows.Forms.MenuItem("Turbo") $Menu_Perf_Turbo = New-Object System.Windows.Forms.MenuItem("Turbo")
@@ -229,30 +243,46 @@ $Menu_Autostart = New-Object System.Windows.Forms.MenuItem("Run on startup")
$Menu_Exit = New-Object System.Windows.Forms.MenuItem("Exit") $Menu_Exit = New-Object System.Windows.Forms.MenuItem("Exit")
$contextmenu = New-Object System.Windows.Forms.ContextMenu $contextmenu = New-Object System.Windows.Forms.ContextMenu
$contextmenu.MenuItems.AddRange($Menu_Perf_Title)
$contextmenu.MenuItems.AddRange($Menu_Perf_Silent)
$contextmenu.MenuItems.AddRange($Menu_Perf_Balanced)
$contextmenu.MenuItems.AddRange($Menu_Perf_Turbo)
$contextmenu.MenuItems.AddRange("-")
$contextmenu.MenuItems.AddRange($Menu_Title)
$contextmenu.MenuItems.AddRange($Menu_Eco)
$contextmenu.MenuItems.AddRange($Menu_Standard)
$contextmenu.MenuItems.AddRange($Menu_Ultimate)
$contextmenu.MenuItems.AddRange("-")
$contextmenu.MenuItems.AddRange($Menu_RR)
$contextmenu.MenuItems.AddRange($Menu_RR60)
$contextmenu.MenuItems.AddRange($Menu_RR120)
$contextmenu.MenuItems.AddRange($Menu_OD)
$contextmenu.MenuItems.AddRange("-")
$Menu_Charge60 = New-Object System.Windows.Forms.MenuItem("60%")
$Menu_Charge80 = New-Object System.Windows.Forms.MenuItem("80%")
$Menu_Charge100 = New-Object System.Windows.Forms.MenuItem("100%")
$Submenu_Charge = New-Object System.Windows.Forms.MenuItem("Charge Limit")
$Submenu_Charge.MenuItems.AddRange($Menu_Charge60)
$Submenu_Charge.MenuItems.AddRange($Menu_Charge80)
$Submenu_Charge.MenuItems.AddRange($Menu_Charge100)
$contextmenu.MenuItems.AddRange($Submenu_Charge)
$contextmenu.MenuItems.AddRange("-")
$contextmenu.MenuItems.AddRange($Menu_Autostart)
$contextmenu.MenuItems.AddRange("-")
$contextmenu.MenuItems.AddRange($Menu_Exit)
$Main_Tool_Icon.ContextMenu = $contextmenu $Main_Tool_Icon.ContextMenu = $contextmenu
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Perf_Title)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Perf_Silent)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Perf_Balanced)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Perf_Turbo)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange("-")
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Title)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Eco)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Standard)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Ultimate)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange("-")
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_RR)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_RR60)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_RR120)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_OD)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange("-")
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Autostart)
$Main_Tool_Icon.contextMenu.MenuItems.AddRange("-")
$Main_Tool_Icon.contextMenu.MenuItems.AddRange($Menu_Exit)
# Hardware Initialisation # Hardware Initialisation
@@ -389,13 +419,40 @@ function SetPeformanceMode ($performance_mode = 0) {
SaveConfigSetting -Name 'performance_mode' -Value $performance_mode SaveConfigSetting -Name 'performance_mode' -Value $performance_mode
UICheckStats UICheckStats
Invoke-CimMethod $asushw -MethodName DEVS -Arguments @{Device_ID=$device_performance ; Control_status=$performance_mode } Invoke-CimMethod $asushw -MethodName DEVS -Arguments @{Device_ID=$device_performance ; Control_status=$performance_mode } | Out-Null
WriteLog("Performance set to "+$performance_mode) WriteLog("Performance set to "+$performance_mode)
} }
function SetChargeLimit ($charge_limit = 100) {
$Menu_Charge60.Checked = $false;
$Menu_Charge80.Checked = $false;
$Menu_Charge100.Checked = $false;
switch ($charge_limit)
{
60 {
$Menu_Charge60.Checked = $true
}
80 {
$Menu_Charge80.Checked = $true
}
Default {
$Menu_Charge100.Checked = $true
$charge_limit = 100
}
}
SaveConfigSetting -Name 'charge_limit' -Value $charge_limit
$Submenu_Charge.Text = "Charge Limit: $charge_limit%"
Invoke-CimMethod $asushw -MethodName DEVS -Arguments @{Device_ID=0x00120057 ; Control_status=$charge_limit } | Out-Null
WriteLog("Charge limit set to "+$charge_limit)
}
function SetPanelOverdrive ($overdrive = 1) { function SetPanelOverdrive ($overdrive = 1) {
SaveConfigSetting -Name 'panel_overdrive' -Value $overdrive SaveConfigSetting -Name 'panel_overdrive' -Value $overdrive
Invoke-CimMethod $asushw -MethodName DEVS -Arguments @{Device_ID=$device_overdrive ; Control_status=$overdrive } Invoke-CimMethod $asushw -MethodName DEVS -Arguments @{Device_ID=$device_overdrive ; Control_status=$overdrive } | Out-Null
WriteLog("Panel Overdrive set to "+$overdrive) WriteLog("Panel Overdrive set to "+$overdrive)
} }
@@ -487,7 +544,7 @@ function UIGPUMode ($gpu_mode) {
$Main_Tool_Icon.Icon = $icon_eco $Main_Tool_Icon.Icon = $icon_eco
} }
"ultimate" { "ultimate" {
$script:title_gpu = "GPU: dGPU exclusive" $script:title_gpu = "GPU: dGPU"
$Menu_Ultimate.Checked = $true $Menu_Ultimate.Checked = $true
$Main_Tool_Icon.Icon = $icon_ultimate $Main_Tool_Icon.Icon = $icon_ultimate
} }
@@ -507,6 +564,7 @@ LoadConfig
SetPeformanceMode(GetConfigSetting('performance_mode')) SetPeformanceMode(GetConfigSetting('performance_mode'))
SetPanelOverdrive(GetConfigSetting('panel_overdrive')) SetPanelOverdrive(GetConfigSetting('panel_overdrive'))
SetChargeLimit(GetConfigSetting('charge_limit'))
GetGPUMode GetGPUMode
@@ -566,6 +624,18 @@ $Menu_RR120.add_Click({
CheckScreen CheckScreen
}) })
$Menu_Charge60.add_Click({
SetChargeLimit(60)
})
$Menu_Charge80.add_Click({
SetChargeLimit(80)
})
$Menu_Charge100.add_Click({
SetChargeLimit(100)
})
$Menu_OD.add_Click({ $Menu_OD.add_Click({
if ($Menu_OD.Checked) { if ($Menu_OD.Checked) {
SetPanelOverdrive(0) SetPanelOverdrive(0)
@@ -591,6 +661,12 @@ $Menu_Exit.add_Click({
Stop-Process $pid Stop-Process $pid
}) })
# Make PowerShell Disappear
$windowcode = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
$asyncwindow = Add-Type -MemberDefinition $windowcode -name Win32ShowWindowAsync -namespace Win32Functions -PassThru
$null = $asyncwindow::ShowWindowAsync((Get-Process -PID $pid).MainWindowHandle, 0)
# Force garbage collection just to start slightly lower RAM usage. # Force garbage collection just to start slightly lower RAM usage.
[System.GC]::Collect() [System.GC]::Collect()
@@ -598,3 +674,5 @@ $Menu_Exit.add_Click({
# This helps with responsiveness, especially when clicking Exit. # This helps with responsiveness, especially when clicking Exit.
$appContext = New-Object System.Windows.Forms.ApplicationContext $appContext = New-Object System.Windows.Forms.ApplicationContext
[void][System.Windows.Forms.Application]::Run($appContext) [void][System.Windows.Forms.Application]::Run($appContext)

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B