mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added Run on Startup option
This commit is contained in:
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PowerShell: Launch Script",
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"script": "powershell \"${workspaceFolder}/ghelper-compile.ps1\"",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
g14-helper.exe
BIN
g14-helper.exe
Binary file not shown.
57
gpu.ps1
57
gpu.ps1
@@ -4,6 +4,44 @@
|
||||
[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
|
||||
}
|
||||
return $psScriptPath
|
||||
}
|
||||
|
||||
|
||||
function SetAutostart () {
|
||||
$taskName = "G14Helper"
|
||||
$task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
||||
if ($task -ne $null) {return }
|
||||
|
||||
$scriptDir = Get-PSScriptPath
|
||||
|
||||
$action = New-ScheduledTaskAction -Execute $scriptDir
|
||||
$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
|
||||
SaveConfigSetting -Name 'autostart' -Value 1
|
||||
}
|
||||
|
||||
function CheckAutostart () {
|
||||
$task = Get-ScheduledTask -TaskName "G14Helper" -ErrorAction SilentlyContinue
|
||||
$Menu_Autostart.Checked = ($task -ne $null)
|
||||
}
|
||||
|
||||
function DisableAutostart () {
|
||||
Unregister-ScheduledTask -TaskName "G14Helper" -Confirm:$false
|
||||
SaveConfigSetting -Name 'autostart' -Value 0
|
||||
}
|
||||
|
||||
function Set-ScreenRefreshRate
|
||||
{
|
||||
param (
|
||||
@@ -185,6 +223,9 @@ $Menu_RR60 = New-Object System.Windows.Forms.MenuItem("60Hz")
|
||||
$Menu_RR120 = New-Object System.Windows.Forms.MenuItem("120Hz")
|
||||
$Menu_OD = New-Object System.Windows.Forms.MenuItem("Panel Overdrive")
|
||||
|
||||
|
||||
$Menu_Autostart = New-Object System.Windows.Forms.MenuItem("Run on startup")
|
||||
|
||||
$Menu_Exit = New-Object System.Windows.Forms.MenuItem("Exit")
|
||||
|
||||
$contextmenu = New-Object System.Windows.Forms.ContextMenu
|
||||
@@ -207,6 +248,9 @@ $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)
|
||||
|
||||
@@ -465,12 +509,14 @@ SetPeformanceMode(GetConfigSetting('performance_mode'))
|
||||
SetPanelOverdrive(GetConfigSetting('panel_overdrive'))
|
||||
|
||||
GetGPUMode
|
||||
|
||||
CheckAutostart
|
||||
CheckScreen
|
||||
|
||||
|
||||
$timer = New-Object System.Windows.Forms.Timer
|
||||
$timer.Add_Tick({UICheckStats})
|
||||
$timer.Interval = 3000
|
||||
$timer.Interval = 5000
|
||||
$timer.Enabled = $True
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
@@ -529,6 +575,15 @@ $Menu_OD.add_Click({
|
||||
CheckScreen
|
||||
})
|
||||
|
||||
$Menu_Autostart.add_Click({
|
||||
if ($Menu_Autostart.Checked) {
|
||||
DisableAutostart
|
||||
} else {
|
||||
SetAutostart
|
||||
}
|
||||
CheckAutostart
|
||||
})
|
||||
|
||||
|
||||
# When Exit is clicked, close everything and kill the PowerShell process
|
||||
$Menu_Exit.add_Click({
|
||||
|
||||
Reference in New Issue
Block a user