Skip to content

Instantly share code, notes, and snippets.

@vetleledaal
Last active June 14, 2019 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vetleledaal/f795f120ba3e7bce649ac5ebd7938e78 to your computer and use it in GitHub Desktop.
Save vetleledaal/f795f120ba3e7bce649ac5ebd7938e78 to your computer and use it in GitHub Desktop.
List installed Twitch games.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
import winreg
except ImportError:
import _winreg as winreg # Python 2
# Test WOW registry
try:
winreg.QueryReflectionKey(winreg.HKEY_LOCAL_MACHINE)
archs = {winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY}
except NotImplemented:
archs = {0}
twitch_games = []
for arch in archs:
key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
u'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
0,
winreg.KEY_READ | arch
)
for i in range(winreg.QueryInfoKey(key)[0]):
skey = winreg.EnumKey(key, i)
with winreg.OpenKey(key, skey) as h:
try:
path = winreg.QueryValueEx(h, 'InstallLocation')[0]
if u'\\Twitch\\Games Library\\' in path:
name = winreg.QueryValueEx(h, 'DisplayName')[0]
twitch_games.append((name, path))
except OSError:
pass
winreg.CloseKey(key)
twitch_games.sort(key=lambda tup: tup[0].lower())
for name, path in twitch_games:
print('%s %s' % (name.ljust(32-1, ' '), path))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment