Advertisement
tabnation

low high

Apr 18th, 2022
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. ;v1 AHK
  2.  
  3. ; Settings
  4. SetBatchLines, 5
  5. OnExit, ExitSub
  6. SetTimer, CheckActiveProcess, 10000
  7.  
  8. ; Variables
  9. global procIDList := Object()
  10. global wPID_old := ""
  11.  
  12. ; Routines
  13. R_GetProcessFullList()
  14. {
  15. procIDList := Object()
  16. procObj := ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
  17. for proc in procObj
  18. procIDList[proc.processId] := proc.Name
  19. }
  20. R_SetProcessPrio(pProcID, pState := "normal")
  21. {
  22. if (pProcID == "*") ; set given prio to all processes
  23. { for pID, pName in procIDList
  24. Process, Priority, % pID, % pState
  25. }
  26. if (pProcID == "*others") ; set given prio to all other processes
  27. {
  28. for pID, pName in procIDList
  29. {
  30. if (pID != wPID_old)
  31. {
  32. Process, Priority, % pID, % pState
  33. }
  34. }
  35. else
  36. {
  37. Process, Priority, % pProcID, % pState
  38. }
  39. return
  40.  
  41. ; GoSubs / Timer
  42. CheckActiveProcess:
  43. WinGet, wPID, PID, A
  44. if (wPID != wPID_old)
  45. {
  46. R_SetProcessPrio(wPID,"High")
  47. wPID_old := wPID
  48. R_GetProcessFullList()
  49. R_SetProcessPrio("*others","Low")
  50. }
  51. return
  52.  
  53. ; Exit
  54. ExitSub:
  55. R_SetProcessPrio("*") ; set all processes to "normal"
  56. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement