Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;v1 AHK
- ; Settings
- SetBatchLines, 5
- OnExit, ExitSub
- SetTimer, CheckActiveProcess, 10000
- ; Variables
- global procIDList := Object()
- global wPID_old := ""
- ; Routines
- R_GetProcessFullList()
- {
- procIDList := Object()
- procObj := ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
- for proc in procObj
- procIDList[proc.processId] := proc.Name
- }
- R_SetProcessPrio(pProcID, pState := "normal")
- {
- if (pProcID == "*") ; set given prio to all processes
- { for pID, pName in procIDList
- Process, Priority, % pID, % pState
- }
- if (pProcID == "*others") ; set given prio to all other processes
- {
- for pID, pName in procIDList
- {
- if (pID != wPID_old)
- {
- Process, Priority, % pID, % pState
- }
- }
- else
- {
- Process, Priority, % pProcID, % pState
- }
- return
- ; GoSubs / Timer
- CheckActiveProcess:
- WinGet, wPID, PID, A
- if (wPID != wPID_old)
- {
- R_SetProcessPrio(wPID,"High")
- wPID_old := wPID
- R_GetProcessFullList()
- R_SetProcessPrio("*others","Low")
- }
- return
- ; Exit
- ExitSub:
- R_SetProcessPrio("*") ; set all processes to "normal"
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement