Skip to content

Instantly share code, notes, and snippets.

@AliAlmasi
Created March 15, 2025 16:21
Show Gist options
  • Save AliAlmasi/43e5a640852bd03f84f021d0c068fcd6 to your computer and use it in GitHub Desktop.
Save AliAlmasi/43e5a640852bd03f84f021d0c068fcd6 to your computer and use it in GitHub Desktop.
Change Windows 11 context menu style (legacy style and Fluent UI style)
import time, os, sys
from sty import fg, ef, rs # pip install sty
def typing(str):
for char in str:
time.sleep(0.05)
sys.stdout.write(char)
sys.stdout.flush()
print("\n")
name = "Win11 Context Menu Switcher"
typing(f"{ef.bold}{name}{rs.all}")
typing("By: Ali Almasi")
print("\n")
os.system(f"title {name}")
time.sleep(1)
reg_add = 'reg.exe add "HKCU\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\\InprocServer32" /f /ve'
reg_remove = 'reg.exe delete "HKCU\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f'
explorer_restart = 'cmd /c "taskkill /f /im explorer.exe && start explorer.exe"'
input_prompt = f"Press {ef.bold}1{rs.all} for {ef.underl}legacy context menu{rs.all},\nor press {ef.bold}2{rs.all} for {ef.underl}Fluent UI context menu{rs.all}: {fg.yellow}"
os_error = f"This program is only for {ef.bold}{fg.blue}Microsoft Windows{rs.all}."
def main():
if os.name != "nt":
print(os_error)
exit(1)
user_choice = str(input(input_prompt))
print(rs.all)
if user_choice == "1":
print("Switching to legacy menu...")
os.system(reg_add)
elif user_choice == "2":
print("Switching to Fluent UI menu...")
os.system(reg_remove)
else:
print(f"{fg.red}ERROR: Wrong input{rs.all}")
time.sleep(0.5)
print("\n")
main()
if __name__ == "__main__":
main()
os.system(explorer_restart)
print(f"{fg.blue}ALL DONE.{rs.all}")
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment