Last active
February 4, 2022 05:29
-
-
Save xgdgsc/806ec7df51102a2961407bc48c189eef to your computer and use it in GitHub Desktop.
switch power plan based on window name using ahk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance force | |
#warn | |
RyzenPowerPlanIDCheck() | |
{ | |
objShell := ComObjCreate("WScript.Shell") | |
var := objShell.Exec("cmd /c powercfg /list").StdOut.ReadAll() | |
global powercfg_ids := ["381b4222-f694-41f0-9685-ff5bb260df2e","a1841308-3541-4fab-bc81-f71556f20b4a"] | |
for each, id in powercfg_ids | |
{ | |
IfNotInString, var, %id% | |
{ | |
msgbox, Looks like we're missing at least one or more Ryzen power plan ids. Didn't find %id% %var% | |
return | |
} | |
} | |
global powercfg_plan_RyzenBalanced = powercfg_ids[2] | |
global powercfg_plan_RyzenHighPerf = powercfg_ids[1] | |
} | |
RyzenPowerPlanIDCheck() | |
SetTitleMatchMode, 2 | |
GroupAdd, GAMES_ALL, ahk_class UnityWndClass | |
GroupAdd, GAMES_ALL, ahk_class vguiPopupWindow | |
GroupAdd, GAMES_ALL, ahk_class UnrealWindow | |
GroupAdd, GAMES_ALL, ahk_class UUMAINFORMV40 | |
performance_amd_plan = 0 | |
#Persistent | |
SetTimer, CheckGame, 10000 | |
; return | |
CheckGame: | |
ex := WinExist("ahk_group GAMES_ALL") | |
; msgbox, %ex% | |
if (!performance_amd_plan && powercfg_plan_RyzenHighPerf && WinExist("ahk_group GAMES_ALL")) | |
{ | |
performance_amd_plan = 1 | |
; msgbox, perf 1 | |
Run, powercfg -SETACTIVE %powercfg_plan_RyzenHighPerf% | |
} | |
else if (powercfg_plan_RyzenBalanced && performance_amd_plan && !WinExist("ahk_group GAMES_ALL")) | |
{ | |
; msgbox, perf 2 | |
performance_amd_plan = 0 | |
Run, powercfg -SETACTIVE %powercfg_plan_RyzenBalanced% | |
} | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment