insearchofcode
insearchofcode

Reputation: 448

How to edit registry values with Autohotkey?

I made a autohotkey script to toggle appmode in Windows to dark/light them when I click F6 button as follows:

F6::
{
    RegRead, appMode, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, AppsUseLightTheme
    RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, AppsUseLightTheme, !appMode
}

The script is running, but it's not changing the appmode. I'm new to Autohotkey, I think there will be a % sign before variable, but I don't understand where to place it.

Upvotes: 2

Views: 1089

Answers (1)

Relax
Relax

Reputation: 10593

; Toggle appmode in Windows to dark/light:

F6::
    RegRead, appMode, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, AppsUseLightTheme
    ; MsgBox, %appMode%
    If (appMode = 0) ; dark
        RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, AppsUseLightTheme, 1
    else   ; If (appMode = 1) light 
        RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, AppsUseLightTheme, 0
return

https://www.autohotkey.com/docs/commands/RegWrite.htm

Upvotes: 2

Related Questions