Toggling dark mode programmatically
-
Hi!
So, after suffering from the fact that there’s no way to automatically toggle darkmode on/off in Windows 10 I made a simple Scheduled Task that runs this powershell script and that takes care of most things, however there are a few programs that don’t pick up on this OS setting yet.
So, is there a way to alter the Dark Mode setting in N++ programmatically so I don’t need to go into the settings menu and do a couple of clicks to keep it in sync with the OS setting?
(If you know there’re plans to pick up the OS value automatically then I’ll just live with it until it’s implemented, though :D )
-
On program load, Notepad++ decides on Dark Mode based on a setting in
config.xml
(%AppData%\Notepad++\config.xml
in a normal installation). Specifically, the line that is something like,<GUIConfig name="DarkMode" enable="yes" colorTone="0" customColorTop="2105376" customColorMenuHotTrack="4210752" customColorActive="4210752" customColorMain="2105376" customColorError="176" customColorText="14737632" customColorDarkText="12632256" customColorDisabledText="8421504" customColorLinkText="65535" customColorEdge="6579300" customColorHotEdge="10197915" customColorDisabledEdge="4737096" />
So in your script that runs to change Windows 10 mode, you could have that script edit that line in the
config.xml
fromno
toyes
and backActually, there is a second associated line
<GUIConfig name="stylerTheme" path="...\AppData\Roaming\Notepad++\stylers.xml" />
When you switch to Dark Mode, that automaticallyg gets changed to
<GUIConfig name="stylerTheme" path="...\AppData\Roaming\Notepad++\themes\DarkModeDefault.xml" />
… so you will probably want to change both those lines, so it changes the mode and sets the theme.
Note: I used ellipses … in my paths in the example
config.xml
lines, but you will need to make sure that everything up toNotepad++\
stays the same when you make the change.Addenda: In case it wasn’t clear, you can only make that change to
config.xml
when Notepad++ is not running. If Notepad++ is running, it won’t see the change toconfig.xml
, and when it exits, it will overwrite the change you made toconfig.xml
. (And other than programmatically sending the keystrokes or mouse-clicks to the Notepad++ GUI – which is possible but maybe complicated depending on what libraries you use in your coding language of choice – I do not know of a way to tell a “live” instance of Notepad++ to change modes from the outside world.) -
@PeterJones thank you for the reply!
Sadly, I’m trying to make Npp change themes even while it’s running, so I’m leaning towards developing a plugin or a macro or something that will let me do that. I just need a Saturday off or something :D