enhancementgood first issue
Repository metrics
- Stars
- (10 stars)
- PR merge metrics
- (PR metrics pending)
Description
It seems we can use reg query command to to access the registry to find if the application is in dark mode or not.
Detecting if an Application is in Dark Mode in Windows via CLI
Steps:
The registry path for the dark mode setting is:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\PersonalizeThe value to check is:
AppsUseLightTheme(DWORD)If
AppsUseLightThemeis0, the application/system is in dark mode.
IfAppsUseLightThemeis1, the application/system is in light mode.
CLI Command
You can use the following command to check the value:
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v AppsUseLightTheme
Output Example
Dark Mode:
AppsUseLightTheme REG_DWORD 0x0Light Mode:
AppsUseLightTheme REG_DWORD 0x1
Parse the Result in Scripts
Batch Script Example:
for /f "tokens=3" %%A in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v AppsUseLightTheme') do ( if %%A==0x0 ( echo Dark mode is enabled. ) else ( echo Light mode is enabled. ) )PowerShell Script Example:
$regValue = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" if ($regValue.AppsUseLightTheme -eq 0) { Write-Output "Dark mode is enabled." } else { Write-Output "Light mode is enabled." }