Skip to content

Instantly share code, notes, and snippets.

@lancepioch
Created December 9, 2019 06:35
Show Gist options
  • Save lancepioch/215620812e11b8eb915f96fea7b9230e to your computer and use it in GitHub Desktop.
Save lancepioch/215620812e11b8eb915f96fea7b9230e to your computer and use it in GitHub Desktop.
Adjust priorities for MW and Discord to fix voice issues and lag
import wmi, win32api, win32process, win32con
priorityclasses = [win32process.IDLE_PRIORITY_CLASS,
win32process.BELOW_NORMAL_PRIORITY_CLASS,
win32process.NORMAL_PRIORITY_CLASS,
win32process.ABOVE_NORMAL_PRIORITY_CLASS,
win32process.HIGH_PRIORITY_CLASS,
win32process.REALTIME_PRIORITY_CLASS]
# "Recipe 496767: Set Process Priority In Windows" on ActiveState - http://code.activestate.com/recipes/496767/
for process in wmi.WMI().Win32_Process():
if (process.Name == "Discord.exe"):
print(process.ProcessId, process.Name)
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, process.ProcessId)
win32process.SetPriorityClass(handle, win32process.HIGH_PRIORITY_CLASS)
if (process.Name == "ModernWarfare.exe"):
print(process.ProcessId, process.Name)
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, process.ProcessId)
win32process.SetPriorityClass(handle, win32process.ABOVE_NORMAL_PRIORITY_CLASS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment