Last active
January 14, 2019 18:23
-
-
Save motleytech/aca6ccc8029fce901493d0cbe597605d to your computer and use it in GitHub Desktop.
Python 3 Script to edit Registry for reversing mouse scroll direction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from winreg import * | |
import os | |
def is_admin(): | |
if os.name == 'nt': | |
try: | |
# only windows users with admin privileges can read the C:\windows\temp | |
temp = os.listdir(os.sep.join([os.environ.get('SystemRoot','C:\\windows'),'temp'])) | |
except: | |
return False | |
else: | |
return True | |
else: | |
print('This is a windows script.') | |
exit(1) | |
"""print r"*** Reading from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID ***" """ | |
def main(): | |
if not is_admin(): | |
print('Must have admin privileges to run this script.') | |
exit(1) | |
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) | |
FLIP_FLOP_VALUE = 1 | |
aKey = OpenKey(aReg, r"SYSTEM\CurrentControlSet\Enum\HID") | |
for i in range(1024): | |
try: | |
asubkey_name = EnumKey(aKey, i) | |
asubkey = OpenKey(aKey, asubkey_name) | |
for j in range(1024): | |
try: | |
bsubkey_name = EnumKey(asubkey, j) | |
bsubkey = OpenKey(asubkey, bsubkey_name) | |
for k in range(1024): | |
try: | |
csubkey_name = EnumKey(bsubkey, k) | |
if csubkey_name != 'Device Parameters': | |
continue | |
csubkey = OpenKey(bsubkey, csubkey_name, 0, KEY_ALL_ACCESS) | |
val = QueryValueEx(csubkey, "FlipFlopWheel") | |
print((asubkey_name, bsubkey_name, csubkey_name)) | |
SetValueEx(csubkey, 'FlipFlopWheel', 0, REG_DWORD, FLIP_FLOP_VALUE) | |
CloseKey(csubkey) | |
print('Set FFW : %s' % FLIP_FLOP_VALUE) | |
except error as e: | |
if 'No more data' in e.strerror: | |
break | |
continue | |
except error as e: | |
if 'No more data' in e.strerror: | |
break | |
continue | |
except error as e: | |
if 'No more data' in e.strerror: | |
break | |
continue | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment