Change w7 theme (for automatic postinstall)

Get help with using AutoHotkey and its commands and hotkeys
Posts: 21
Joined: 29 Apr 2016, 22:09

Change w7 theme (for automatic postinstall)

11 Jun 2016, 01:47

Hello everybody,

I've used Autohotkey for many years and really love it. I've joined this forum only a couple of weeks ago and have already received some wonderful help and tips, thanks!!!

I'm looking for code to change the Windows 7 theme automatically. This is the only thing I've never been able to do in my little Autohotkey Postinstall thingy (which is just a simple program with lots of setup /S [silent] installs, registry settings, ini copying, etc. etc.).

This is what I'm doing now:

Code: Select all

 runwait,c:\Windows\System32\rundll32.exe c:\Windows\System32\shell32.dll`,Control_RunDLL c:\windows\system32\desk.cpl desk`,@Themes /Action:OpenTheme /file:"c:\windows\resources\ease of access themes\classic.theme"
  winwait,Personal settings [translated back from my local text]
  msgbox,4096,Classic Theme,Hit Enter when the Classic Theme is set
  winactivate,Personal settings
This is working correctly, I'm just looking for a more automated method, without user intervention or windows popping up.

I've also tried to modify the Windows 7 install.wim file to have the Classic Theme in there by default, but that's not an easy task. If there's a way to do this ("silently") in Autohotkey, that would be great...
Thanks again to everybody on this great forum, and thanks to the Autohotkey developers!!
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
GitHub: CapnOdin
Location: Denmark

Re: Change w7 theme (for automatic postinstall)

11 Jun 2016, 05:52

Try adding Min to your Run command. Hide doesn't seam to work. You may need to close the window later, but at least on my computer only the "Please wait" or whatever it says in english is displayed

Code: Select all

Run, c:\Windows\System32\rundll32.exe c:\Windows\System32\shell32.dll`,Control_RunDLL c:\windows\system32\desk.cpl desk`,@Themes /Action:OpenTheme /file:"c:\windows\resources\ease of access themes\classic.theme", , Min
or maybe this is closer to what you want ... users.html
Please excuse my spelling I am dyslexic.
Posts: 468
Joined: 04 Mar 2016, 04:33
GitHub: qwerty12

Re: Change w7 theme (for automatic postinstall)

11 Jun 2016, 08:48


After looking through C:\Windows\diagnostics\system\AERO\CL_Utility.ps1 (thanks to Microsoft for exposing the interface - you'd be surprised at what you can find in that folder on old Windows versions...), here's something to try to apply a theme directly with AutoHotkey. ApplyTheme will set the theme and block the script until its work is done without bringing up any dialog boxes (though you will see "Please wait"):

Code: Select all

themePath := A_WinDir . "\Resources\Ease of Access Themes\classic.theme"
if (FileExist(themePath))
	try themeManager := ComObjCreate(CLSID_IThemeManager := "{C04B329E-5823-4415-9C93-BA44688947B0}", IID_IThemeManager := "{0646EBBE-C1B7-4045-8FD0-FFD65D3FC792}")	
	if (themeManager) {
		themeBstr := DllCall("oleaut32\SysAllocString", "WStr", themePath, "Ptr")
		if (themeBstr) {
			DllCall(NumGet(NumGet(themeManager+0)+4*A_PtrSize), "Ptr", themeManager, "Ptr", themeBstr) ; ::ApplyTheme
			DllCall("oleaut32\SysFreeString", "Ptr", themeBstr)
Posts: 21
Joined: 29 Apr 2016, 22:09

Re: Change w7 theme (for automatic postinstall)

11 Jun 2016, 23:45

Capn Odin: Thank you for your reply. Thanks for finding the link to that SevenForums article, I actually read that before, as you can see it is quite a complicated affair, the article also mentions it sometimes doesn't work for 64bit, etc. So that's why I said "not an easy task" in my original question.

Qwerty12: WOW!!! That is an amazing piece of code!
To test, I restored my TeraByte disk image of a clean Windows 7 (default theme, default everything). On a different PC, I compiled your code to "SetClassicTheme.exe", put it on a USB and ran it on the w7 PC.

Wow again, this is a thing of great beauty! Thank you so much! (Hey, you're the same guy who helped me on the HTTPRequest issue!)
As I said, this was pretty much the only "manual" step left in my PostInstall (using a button "Set Theme" and the code in my first post).
I really can't tell you (both of you!) how much I appreciate your help!

Return to “Ask For Help”

Who is online

Users browsing this forum: JollyJoeHelpMePls, mikeyww, mrmech, sws224, tertius, XMCQCX and 70 guests