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
|
||||
run: |
|
||||
mkdir release
|
||||
cp *.exe ./release
|
||||
cp *.cmd ./release
|
||||
cp *.lnk ./release
|
||||
cp ghelper.ps1 ./release
|
||||
zip -r g14-helper.zip ./release
|
||||
zip -r g14-helper-script.zip ./release
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
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
|
||||
.\g14-helper.exe
|
||||
ps2exe .\ghelper.ps1 g14-helper.exe -title 'G14 Helper' -DPIAware -winFormsDPIAware -requireAdmin -iconFile 'standard.ico' -noConsole -copyright 'G14 Helper Tool' -noOutput
|
||||
59
ghelper.ps1
59
ghelper.ps1
@@ -1,27 +1,40 @@
|
||||
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | out-null
|
||||
[System.Reflection.Assembly]::LoadWithPartialName('presentationframework') | out-null
|
||||
[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') | out-null
|
||||
[System.Reflection.Assembly]::LoadWithPartialName('WindowsFormsIntegration') | out-null
|
||||
|
||||
|
||||
Function Get-PSScriptPath {
|
||||
if ([System.IO.Path]::GetExtension($PSCommandPath) -eq '.ps1') {
|
||||
$psScriptPath = $PSCommandPath
|
||||
} else {
|
||||
$psScriptPath = [System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName
|
||||
# Self-elevate the script
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine -WindowStyle Hidden
|
||||
Exit
|
||||
}
|
||||
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 () {
|
||||
$taskName = "G14Helper"
|
||||
$task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
||||
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
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||
|
||||
@@ -406,7 +419,7 @@ function SetPeformanceMode ($performance_mode = 0) {
|
||||
SaveConfigSetting -Name 'performance_mode' -Value $performance_mode
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -432,14 +445,14 @@ function SetChargeLimit ($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 }
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -647,11 +660,19 @@ $Menu_Exit.add_Click({
|
||||
$Main_Tool_Icon.Visible = $false
|
||||
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.
|
||||
[System.GC]::Collect()
|
||||
|
||||
# Create an application context for it to all run within.
|
||||
# This helps with responsiveness, especially when clicking Exit.
|
||||
$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