Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Lock Advanced Window Settings, Screensaver, etc. in Win 7 (propagates settings to all themes)


  • Please log in to reply
No replies to this topic
chaz
  • Members
  • 192 posts
  • Last active: Oct 01 2015 02:42 AM
  • Joined: 26 Mar 2013

I wrote this script because it drove me up the wall when every time I changed the Personalisation theme in Windows 7, all the advanced window settings (e.g. scrollbar width) and the screensaver changed with it. I have never understood this behaviour, because those settings shouldn't be something that change with the theme and always thought there should be an option to make it so they don't change with the theme, like in the cursor options.

 

This script changes the settings in all theme configuration files in the user themes folder. Right now it overwrites any existing settings (only screensaver and advanced window settings), but I plan to make it so specific themes can be ignored (that is, their settings not overwritten) by adding a value to the configuration file which the script reads before overwriting.

 

Here's the script:

; Propagate Advanced Window Settings
; Version 0.9

#Persistent
#SingleInstance, force

global path := UserProfile "\AppData\Local\Microsoft\Windows\Themes\"

main()
return

;
; Main Entry Point
;

main()
{
    Loop
    {
        trigger()		
        message("Start")
        Sleep 200		; wait while registry settings are written
        propSettings()
        message("Finish")
    }
}

;
; Handle Settings
;

getFileList()
{
    ; CSV of every *.theme file in the user themes folder
    Loop,  %path%*.theme, 0, 1
        fileList := fileList A_LoopFileLongPath "`n"
    ;~ MsgBox, File list:`n%fileList%
    return fileList
}

getColours()
{
    Loop, HKEY_CURRENT_USER, Control Panel\Colors
    {
        RegRead, currentItemValue
        if A_Index = 1
            colourValuesList := "[Control Panel\Colors]`n" A_LoopRegName "=" currentItemValue
        else colourValuesList := colourValuesList "`n" A_LoopRegName "=" currentItemValue
    }
    return colourValuesList
}

getScrnsaver()
{
    RegRead, scrnsaver, HKEY_CURRENT_USER, Control Panel\Desktop, SCRNSAVE.EXE
    return scrnsaver
}

getMetrics()
{
    ;...
}

;
; Utility Functions
;

trigger()
{
    WinWait, ahk_class #32770
    if WinActive("Window Color and Appearance")
        WinWaitClose, ahk_class #32770
    if WinActive("Screen Saver Settings")
    {
        WinWaitClose, ahk_class #32770
        WinClose, Control Panel\All Control Panel Items\Personalization ahk_class CabinetWClass
        Run, control desktop
    }
    else trigger()
}

message(type)
{
    if type = Start
        MsgBox, Starting propagation of advanced window settings to all themes.`nPlease wait until the process is complete before continuing.
    else if type = Finish
        MsgBox, Propagation is complete.
}

propSettings()		; propagate settings
{
    fileList := getFileList()
    Loop, Parse, fileList, `n
    {
        IniWrite, % getScrnsaver(), %A_LoopField%, Boot, scrnsave.exe
        
        ; Colours
        IniDelete, %A_LoopField%, Control Panel\Colors	; delete the whole section
        FileAppend, % getColours(), %A_LoopField%
        
        ; Metrics
        ; ...
    }
}

Right now the script is not fully complete because I am having trouble converting the registry values for the window metrics (though it works for everything else) to the format in which it is in the configuration file. For example, the window metrics values from the registry look like this (exported from regedit):

Windows Registry Editor Version 5.00
[HKEY_USERS\.DEFAULT\Control Panel\Desktop\WindowMetrics]
"BorderWidth"="-15"
"ScrollWidth"="-255"
"ScrollHeight"="-255"
"CaptionWidth"="-315"
"CaptionHeight"="-315"
"SmCaptionWidth"="-255"
"SmCaptionHeight"="-255"
"MenuWidth"="-285"
"MenuHeight"="-285"
"CaptionFont"=hex:f4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\  
00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"SmCaptionFont"=hex:f4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,\  
00,00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"MenuFont"=hex:f4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,\  
00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"StatusFont"=hex:f4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\  
00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"MessageFont"=hex:f4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\  
00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"PaddedBorderWidth"="-60"
"AppliedDPI"=dword:00000060
"IconFont"=hex:f4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,\  
00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\  
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

 But the theme configuration file looks like this:

[Metrics]
NonclientMetrics=88 1 0 0 1 0 0 0 24 0 0 0 24 0 0 0 21 0 0 0 21 
0 0 0 244 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 144 1 0 0 0 0 0 1 0 0 5 0 83 101 
103 111 101 32 85 73 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 0 0 0 17 
0 0 0 244 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 144 1 0 0 0 0 0 1 0 0 5 0 83 101 
103 111 101 32 85 73 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19 0 0 0 19 
0 0 0 244 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 144 1 0 0 0 0 0 1 0 0 5 0 83 101 
103 111 101 32 85 73 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 244 255 255 
255 0 0 0 0 0 0 0 0 0 0 0 0 144 1 0 0 0 0 0 1 0 0 5 0 83 101 103 111 101 32 85 
73 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 244 255 255 255 0 0 0 0 0 0 0 
0 0 0 0 0 144 1 0 0 0 0 0 1 0 0 5 0 83 101 103 111 101 32 85 73 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0

IconMetrics=76 0 0 0 75 0 0 0 75 0 0 0 1 0 0 0 244 255 255 255 0 0 0 0 0 0 0 
0 0 0 0 0 144 1 0 0 0 0 0 1 0 0 5 0 83 101 103 111 101 32 85 73 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

How do I convert from one to the other?

Comments, constructive criticism, and help for the problem I described above are appreciated.


Find me at the other forum as timeFlies.