mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Separate package with ps1 script only
This commit is contained in:
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@@ -19,13 +19,15 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
mkdir release
|
mkdir release
|
||||||
cp *.exe ./release
|
cp *.cmd ./release
|
||||||
|
cp *.lnk ./release
|
||||||
cp ghelper.ps1 ./release
|
cp ghelper.ps1 ./release
|
||||||
zip -r g14-helper.zip ./release
|
zip -r g14-helper-script.zip ./release
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
g14-helper.zip
|
g14-helper-script.zip
|
||||||
|
g14-helper.exe
|
||||||
|
|
||||||
|
|||||||
BIN
G14-Helper.lnk
Normal file
BIN
G14-Helper.lnk
Normal file
Binary file not shown.
13
events.ps1
Normal file
13
events.ps1
Normal 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
1
g14-helper.cmd
Normal file
@@ -0,0 +1 @@
|
|||||||
|
powershell -WindowStyle hidden -file ghelper.ps1
|
||||||
BIN
g14-helper.exe
BIN
g14-helper.exe
Binary file not shown.
@@ -1,2 +1 @@
|
|||||||
ps2exe .\ghelper.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
|
|
||||||
55
ghelper.ps1
55
ghelper.ps1
@@ -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 ($null -ne $task) {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
|
||||||
|
|
||||||
@@ -406,7 +419,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,14 +445,14 @@ function SetChargeLimit ($charge_limit = 100) {
|
|||||||
|
|
||||||
SaveConfigSetting -Name 'charge_limit' -Value $charge_limit
|
SaveConfigSetting -Name 'charge_limit' -Value $charge_limit
|
||||||
$Submenu_Charge.Text = "Charge Limit: $charge_limit%"
|
$Submenu_Charge.Text = "Charge Limit: $charge_limit%"
|
||||||
Invoke-CimMethod $asushw -MethodName DEVS -Arguments @{Device_ID=0x00120057 ; Control_status=$charge_limit }
|
Invoke-CimMethod $asushw -MethodName DEVS -Arguments @{Device_ID=0x00120057 ; Control_status=$charge_limit } | Out-Null
|
||||||
WriteLog("Charge limit set to "+$charge_limit)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,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()
|
||||||
|
|
||||||
@@ -655,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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user