emf
2014-11-20 04:38:19 UTC
I my old machine I had a file to toggle between 2 themes, black.thmeme
and white.theme, by clicking at a desktop link to the file. I think I've
made the necessary adjustments, but the script does not work well in
Windows 7. Here is the code:
===================================
Set WshShell = WScript.CreateObject("WScript.shell")
theme1 =
"C:\Users\Eustace\AppData\Local\Microsoft\Windows\Themes\Black.theme"
theme2 =
"C:\Users\Eustace\AppData\Local\Microsoft\Windows\Themes\White.theme"
'Theme names
themename1 = mid(Theme1,instrrev(theme1,"\")+1)
themename2 = mid(Theme2,instrrev(theme2,"\")+1)
'Check current theme
on error resume next
themekey =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme"
currenttheme = wshshell.regread(themekey)
currentthemename = mid(currenttheme,instrrev(currenttheme,"\")+1)
on error goto 0
'Choose theme to apply
If trim(lcase(currentthemename)) = trim(lcase(themename1)) then
theme = theme2
thememessage = left(themename2,instrrev(themename2,".")-1)
else
theme = theme1
thememessage = left(themename1,instrrev(themename1,".")-1)
end if
'Apply the theme
runstring = chr(34) & theme & chr(34)
WshShell.Run runstring
'Activate the window
counter = 600
activated = false
do
activated = WshShell.AppActivate("Display Properties")
wscript.sleep 100
counter = counter - 1
if counter = 0 then
wscript.quit
end if
loop until activated = true
wshshell.sendkeys "{ENTER}"
===================================
The major issue is that though when the current theme is not
black.theme, it correctly changes the theme to black.theme; but when the
theme is black.theme, it does not change it to white.theme. I suspect
that the condition
trim(lcase(Currentthemename)) = trim(lcase(Themename1))
in the if-else is always false, so that it always runs the else commands.
How can I correct this?
Thanks,
emf
and white.theme, by clicking at a desktop link to the file. I think I've
made the necessary adjustments, but the script does not work well in
Windows 7. Here is the code:
===================================
Set WshShell = WScript.CreateObject("WScript.shell")
theme1 =
"C:\Users\Eustace\AppData\Local\Microsoft\Windows\Themes\Black.theme"
theme2 =
"C:\Users\Eustace\AppData\Local\Microsoft\Windows\Themes\White.theme"
'Theme names
themename1 = mid(Theme1,instrrev(theme1,"\")+1)
themename2 = mid(Theme2,instrrev(theme2,"\")+1)
'Check current theme
on error resume next
themekey =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme"
currenttheme = wshshell.regread(themekey)
currentthemename = mid(currenttheme,instrrev(currenttheme,"\")+1)
on error goto 0
'Choose theme to apply
If trim(lcase(currentthemename)) = trim(lcase(themename1)) then
theme = theme2
thememessage = left(themename2,instrrev(themename2,".")-1)
else
theme = theme1
thememessage = left(themename1,instrrev(themename1,".")-1)
end if
'Apply the theme
runstring = chr(34) & theme & chr(34)
WshShell.Run runstring
'Activate the window
counter = 600
activated = false
do
activated = WshShell.AppActivate("Display Properties")
wscript.sleep 100
counter = counter - 1
if counter = 0 then
wscript.quit
end if
loop until activated = true
wshshell.sendkeys "{ENTER}"
===================================
The major issue is that though when the current theme is not
black.theme, it correctly changes the theme to black.theme; but when the
theme is black.theme, it does not change it to white.theme. I suspect
that the condition
trim(lcase(Currentthemename)) = trim(lcase(Themename1))
in the if-else is always false, so that it always runs the else commands.
How can I correct this?
Thanks,
emf