Skip to content

Instantly share code, notes, and snippets.

@Leokuma
Last active November 20, 2022 18:44
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 Leokuma/5c581cb937f7c057243b7aa1c8e2d38c to your computer and use it in GitHub Desktop.
Save Leokuma/5c581cb937f7c057243b7aa1c8e2d38c to your computer and use it in GitHub Desktop.
[AHK] Toggle dark mode (Win11)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoTrayIcon ; If you don't want a tray icon for this AutoHotkey program.
#SingleInstance force ; Skips the dialog box and replaces the old instance automatically
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir, %A_ScriptDir% ; Set default directory to where this script file is located. (Note %% because it's expecting and unquoted string)
NumpadUp::
RegRead, light, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, SystemUsesLightTheme
if light {
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, SystemUsesLightTheme, 0
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, AppsUseLightTheme, 0
} else {
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, SystemUsesLightTheme, 1
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, AppsUseLightTheme, 1
}
Process, Close, explorer.exe
@Leokuma
Copy link
Author

Leokuma commented Nov 20, 2022

Shortcut: NumPad8 with NumLock turned off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment