Created
May 22, 2020 21:09
-
-
Save ADeltaX/ff12b127896d34ef3f2ed0c4598a0752 to your computer and use it in GitHub Desktop.
Change Theme color (Dark/Light mode) FAST!
This file contains 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
using System; | |
using System.Runtime.InteropServices; | |
using Microsoft.Win32; | |
class Program | |
{ | |
[DllImport("user32.dll", SetLastError = true)] | |
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam); | |
static void Main(string[] args) | |
{ | |
int LightTheme = 0; | |
if (args.Length > 0) | |
{ | |
if (int.TryParse(args[0], out var val)) | |
{ | |
if (val > 1) | |
LightTheme = 1; | |
else if (val < 0) | |
LightTheme = 0; | |
else | |
LightTheme = val; | |
} | |
} | |
RegistryKey k = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default); | |
var wr = k.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", true); | |
wr.SetValue("AppsUseLightTheme", LightTheme, RegistryValueKind.DWord); | |
wr.SetValue("SystemUsesLightTheme", LightTheme, RegistryValueKind.DWord); | |
SendNotifyMessage((IntPtr)0xffff /* Broadcast */, 0x031A, (UIntPtr)0, ""); //WM_THEMECHANGED | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment