Last active
November 23, 2024 19:15
-
-
Save erbanku/eac274bc41baf6fd100013020a8de151 to your computer and use it in GitHub Desktop.
Switch between Light & Dark Mode on Windows 11 using AHK
This file contains hidden or 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
;Switch between Light & Dark Mode on Windows 11 | |
;IN THIS CASE, APPS ON WINDOWS 11 WILL USE LIGHT/DARK MODE | |
^#!A:: | |
; read current theme | |
RegRead, CurrentTheme, % "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", % "AppsUseLightTheme" | |
; toggle between themes | |
RegWrite, REG_DWORD, % "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", % "AppsUseLightTheme", % 1 - CurrentTheme | |
Return | |
;IN THIS CASE, SYSTEMS ON WINDOWS 11 WILL USE LIGHT/DARK MODE | |
^#!L:: | |
; read current theme | |
RegRead, CurrentTheme, % "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", % "SystemUsesLightTheme" | |
; toggle between themes | |
RegWrite, REG_DWORD, % "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", % "SystemUsesLightTheme", % 1 - CurrentTheme | |
Return |
Yes, you can.
Note
Generated by AI, but tested.
1. Enable Dark Mode for Apps
Create a file named EnableDarkModeApps.reg
with the following content:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize]
"AppsUseLightTheme"=dword:00000000
2. Enable Light Mode for Apps
Create a file named EnableLightModeApps.reg
with the following content:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize]
"AppsUseLightTheme"=dword:00000001
3. Enable Dark Mode for System
Create a file named EnableDarkModeSystem.reg
with the following content:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize]
"SystemUsesLightTheme"=dword:00000000
4. Enable Light Mode for System
Create a file named EnableLightModeSystem.reg
with the following content:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize]
"SystemUsesLightTheme"=dword:00000001
Generated by AI, but tested.
@erbanku, thank you! Did you check that they ran merely without errors, or that they actually achieved the desired result?
Anyway, I've transformed them, if of use. This allows them to be invoked via Windows automation software (like Task Scheduler) more easily:
-
Enable-DarkModeApps.PS1
#!/usr/bin/env -S pwsh If ($IsWindows) { If ((Test-Path -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') -NE $True) { New-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Force -EA SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Name 'AppsUseLightTheme' -Value 0 -PropertyType 'DWord' -Force -EA SilentlyContinue; }
-
Enable-LightModeApps.PS1
#!/usr/bin/env -S pwsh If ($IsWindows) { If ((Test-Path -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') -NE $True) { New-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Force -EA SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Name 'AppsUseLightTheme' -Value 1 -PropertyType 'DWord' -Force -EA SilentlyContinue; }
-
Enable-DarkModeSystem.PS1
#!/usr/bin/env -S pwsh If ($IsWindows) { If ((Test-Path -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') -NE $True) { New-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Force -EA SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Name 'SystemUsesLightTheme' -Value 0 -PropertyType 'DWord' -Force -EA SilentlyContinue; }
-
Enable-LightModeSystem.PS1
#!/usr/bin/env -S pwsh If ($IsWindows) { If ((Test-Path -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') -NE $True) { New-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Force -EA SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Name 'SystemUsesLightTheme' -Value 1 -PropertyType 'DWord' -Force -EA SilentlyContinue; }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@erbanku, would
gist.github.com/erbanku/eac274bc41baf6fd100013020a8de151/dc3434b9bf206269d76ee2834bf6b7e875e935a5#file-switch-between-light-dark-mode-on-windows-11-using-ahk-L1-L19
be trivial to convert to a.reg
file? I ask because I want to put it throughgithub.com/rzander/Reg2CI/blob/2f234663e5248c58202530f429eca2b0c1af664d/README.md#reg2ps-website
to replacestackoverflow.com/revisions/73734302/4
.