Advertisement
RshR

PoE-PowerPlan.ahk

Feb 25th, 2022
5,314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; PoE-PowerPlan
  2.  
  3. #SingleInstance force
  4. #NoEnv
  5. #Persistent
  6. SetWorkingDir, %A_ScriptDir%
  7.  
  8. ; Power Plan GUID's can be found with Command prompt: powercfg /list
  9. ; This Power Plan will be activated when PoE window is active
  10. global GUID_POE_DCS := ""
  11.  
  12. ; This Power Plan will be activated when PoE window is not active or PoE not running
  13. global GUID_DEFAULT := "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c" ; High performance default Power Plan
  14.  
  15. global PoEWindow
  16. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile.exe
  17. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_KG.exe
  18. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_EGS.exe
  19. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExileEGS.exe
  20. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExileSteam.exe
  21. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_x64.exe
  22. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_x64_KG.exe
  23. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_x64EGS.exe
  24. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExilex64EGS.exe
  25. GroupAdd, PoEWindow, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_x64Steam.exe
  26.  
  27. global PoEActive := 0
  28.  
  29. OnExit("PPExit")
  30.  
  31. SetTimer, CheckPoEActive, 2000, -100
  32.  
  33. CheckPoEActive()
  34. {
  35.     if WinActive("ahk_group PoEWindow")
  36.     {
  37.         if (PoEActive = 0)
  38.         {
  39.             PoEActive := 1
  40.             PPSetActive(GUID_POE_DCS)
  41.         }
  42.     }
  43.     else
  44.     {
  45.         if (PoEActive = 1)
  46.         {
  47.             PoEActive := 0
  48.             PPSetActive(GUID_DEFAULT)
  49.         }
  50.     }
  51. }
  52.  
  53. PPSetActive(PPGUID)
  54. {
  55.     if StrLen(PPGUID)
  56.         Run, powercfg /setactive %PPGUID%, , Hide
  57. }
  58.  
  59. PPExit(ExitReason, ExitCode)
  60. {
  61.     PPSetActive(GUID_DEFAULT)
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement