Skip to content

Instantly share code, notes, and snippets.

@infval
Created September 22, 2019 23:38
Show Gist options
  • Save infval/e81c938c9799c978b13542e55896172c to your computer and use it in GitHub Desktop.
Save infval/e81c938c9799c978b13542e55896172c to your computer and use it in GitHub Desktop.
[Win7] Explorer search history to file
#!/usr/bin/env python3
import winreg
sub_key = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\WordWheelQuery"
history = []
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, sub_key) as key:
order, regtype = winreg.QueryValueEx(key, "MRUListEx")
ind = 0
while order[ind] != 0xFF:
value, regtype = winreg.QueryValueEx(key, str(order[ind]))
history.append(value)
ind += 4
with open("search_history.txt", "w", encoding="utf-16") as f:
for value in history:
f.write(value.decode("utf-16")[:-1])
f.write("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment