diff --git a/AutoDark.sln b/AutoDark.sln new file mode 100644 index 0000000..80951ff --- /dev/null +++ b/AutoDark.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2027 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoDark", "AutoDark\AutoDark.csproj", "{F24CB25A-C684-4CCB-9346-A0535AB405F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F24CB25A-C684-4CCB-9346-A0535AB405F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F24CB25A-C684-4CCB-9346-A0535AB405F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F24CB25A-C684-4CCB-9346-A0535AB405F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F24CB25A-C684-4CCB-9346-A0535AB405F9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7B70677A-B307-485C-B2F3-186C5D5C8A9D} + EndGlobalSection +EndGlobal diff --git a/AutoDark/AutoDark.cs b/AutoDark/AutoDark.cs new file mode 100644 index 0000000..b8f323a --- /dev/null +++ b/AutoDark/AutoDark.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.Win32; + +namespace AutoDark { + class AutoDark { + static int Main(string[] args) { + int mode = -1; + + if (args.Length > 0 && args[0].Equals("dark", StringComparison.InvariantCultureIgnoreCase)) + mode = 0; + else if (args.Length > 0 && args[0].Equals("light", StringComparison.InvariantCultureIgnoreCase)) + mode = 1; + else if (args.Length > 0) // there is an argument, but it's invalid + return -1; + + RegistryKey k = Registry.CurrentUser.OpenSubKey( + "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", + true + ); + + // if no argument, then just toggle + if (mode == -1) { + string val = k.GetValue("AppsUseLightTheme", 1).ToString(); + mode = int.Parse(val); + if (mode == 1) + mode = 0; + else + mode = 1; + } + + if (k != null) { + k.SetValue("AppsUseLightTheme", mode, RegistryValueKind.DWord); + k.Close(); + } else + return -2; + + return 0; + } + } +} diff --git a/AutoDark/AutoDark.csproj b/AutoDark/AutoDark.csproj new file mode 100644 index 0000000..4c1812e --- /dev/null +++ b/AutoDark/AutoDark.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {F24CB25A-C684-4CCB-9346-A0535AB405F9} + WinExe + AutoDark + AutoDark + v4.7 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + none + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AutoDark/Properties/AssemblyInfo.cs b/AutoDark/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8d1dbe1 --- /dev/null +++ b/AutoDark/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AutoDark")] +[assembly: AssemblyDescription("Sets/toggles the Windows dark mode setting")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AutoDark")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f24cb25a-c684-4ccb-9346-a0535ab405f9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]