Shortcut to toggle themes?

E

Eustace

I have created 2 files to switch between 2 themes, according to earlier
directions from Jon. The one is:

======================================
Set WshShell = WScript.CreateObject("WScript.shell")
Theme = "C:\Documents and Settings\Eustace\My Documents\My White
Theme.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 other is similar except that it refers to My Blue Theme.theme.

So far so good. I have put shortcuts to the 2 files in the Quick Launch
so I can switch the themes from there. I am wondering, however, whether
instead of 2 shortcuts I could have only 1 file that would:

1. detect the current theme
2. if the current theme is not My White Theme apply My White Theme
3. if the current theme is My White Theme apply My Blue Theme

That shouldn't be too difficult, or am I asking too much, Jon?

Thanks,

Eustace
 
J

Jon

Hi Eustace

Sorry for the delay. Was enjoying my weekend :)

Let me know if this works ok [Script below]

NB Put in your 2 theme paths, as previously [lines 2 & 3]. Watch for
wordwrap - all on one line.

NB Remove the last 2 lines if you don't want the information popup, or
modify it with a suitable message of your own choosing . I often find a
reminder message useful, so I've included it.

Because of wordwrap, I'll try and attach the full script to a follow up
message.

For any other modifications you may think of, I would suggest googling for
"Windows Script Host" and vbscript and you will be able to tweak it further
to your heart's desire. Even a small amount of knowledge can go a long way.

Alternatively, if you, or anyone else, have any suggestions for a more
sophisticated program, then you can send me an email [reply to address is
genuine].


Jon


'****************************************************************************
Set WshShell = WScript.CreateObject("WScript.shell")

Theme1="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME1.theme"
Theme2="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME2.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\Plus!\Themes\Current\"
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}"

'Toggle message
WshShell.Popup thememessage & " theme applied" , 3,"Theme Toggler",64

'****************************************************************************
 
J

Jon

Read previous post

Jon

Jon said:
Hi Eustace

Sorry for the delay. Was enjoying my weekend :)

Let me know if this works ok [Script below]

NB Put in your 2 theme paths, as previously [lines 2 & 3]. Watch for
wordwrap - all on one line.

NB Remove the last 2 lines if you don't want the information popup, or
modify it with a suitable message of your own choosing . I often find a
reminder message useful, so I've included it.

Because of wordwrap, I'll try and attach the full script to a follow up
message.

For any other modifications you may think of, I would suggest googling
for "Windows Script Host" and vbscript and you will be able to tweak it
further to your heart's desire. Even a small amount of knowledge can go a
long way.

Alternatively, if you, or anyone else, have any suggestions for a more
sophisticated program, then you can send me an email [reply to address is
genuine].


Jon


'****************************************************************************
Set WshShell = WScript.CreateObject("WScript.shell")

Theme1="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME1.theme"
Theme2="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME2.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\Plus!\Themes\Current\"
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}"

'Toggle message
WshShell.Popup thememessage & " theme applied" , 3,"Theme Toggler",64

'****************************************************************************


Eustace said:
I have created 2 files to switch between 2 themes, according to earlier
directions from Jon. The one is:

======================================
Set WshShell = WScript.CreateObject("WScript.shell")
Theme = "C:\Documents and Settings\Eustace\My Documents\My White
Theme.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 other is similar except that it refers to My Blue Theme.theme.

So far so good. I have put shortcuts to the 2 files in the Quick Launch
so I can switch the themes from there. I am wondering, however, whether
instead of 2 shortcuts I could have only 1 file that would:

1. detect the current theme
2. if the current theme is not My White Theme apply My White Theme
3. if the current theme is My White Theme apply My Blue Theme

That shouldn't be too difficult, or am I asking too much, Jon?

Thanks,

Eustace
 
E

Eustace

Thanks a lot, Jon. The script does what I want it to, and it sits nicely
in the Quick Launch (tools) area, together with the Show desktop, the
Magnifier, and the Performance. I've bookmarked a couple of VBScript
tutorial pages for future reference. The only improvements I could think
of is whether it might be better not to bring up the dialog box and
whether it might get faster, but these are secondary issues. I'll be
posting a request for another shortcut (again having to do with
appearance / accessibility) in another message. -Eustace

Read previous post

Jon

Jon said:
Hi Eustace

Sorry for the delay. Was enjoying my weekend :)

Let me know if this works ok [Script below]

NB Put in your 2 theme paths, as previously [lines 2 & 3]. Watch for
wordwrap - all on one line.

NB Remove the last 2 lines if you don't want the information popup, or
modify it with a suitable message of your own choosing . I often find
a reminder message useful, so I've included it.

Because of wordwrap, I'll try and attach the full script to a follow
up message.

For any other modifications you may think of, I would suggest
googling for "Windows Script Host" and vbscript and you will be able
to tweak it further to your heart's desire. Even a small amount of
knowledge can go a long way.

Alternatively, if you, or anyone else, have any suggestions for a
more sophisticated program, then you can send me an email [reply to
address is genuine].


Jon


'****************************************************************************

Set WshShell = WScript.CreateObject("WScript.shell")

Theme1="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME1.theme"
Theme2="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME2.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\Plus!\Themes\Current\"
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}"

'Toggle message
WshShell.Popup thememessage & " theme applied" , 3,"Theme Toggler",64

'****************************************************************************



Eustace said:
I have created 2 files to switch between 2 themes, according to earlier
directions from Jon. The one is:

======================================
Set WshShell = WScript.CreateObject("WScript.shell")
Theme = "C:\Documents and Settings\Eustace\My Documents\My White
Theme.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 other is similar except that it refers to My Blue Theme.theme.

So far so good. I have put shortcuts to the 2 files in the Quick Launch
so I can switch the themes from there. I am wondering, however, whether
instead of 2 shortcuts I could have only 1 file that would:

1. detect the current theme
2. if the current theme is not My White Theme apply My White Theme
3. if the current theme is My White Theme apply My Blue Theme

That shouldn't be too difficult, or am I asking too much, Jon?

Thanks,

Eustace
 
J

Jon

Thanks for the feedback and good improvement suggestions - I'll perhaps look
into those sometime.

Jon


Eustace said:
Thanks a lot, Jon. The script does what I want it to, and it sits nicely
in the Quick Launch (tools) area, together with the Show desktop, the
Magnifier, and the Performance. I've bookmarked a couple of VBScript
tutorial pages for future reference. The only improvements I could think
of is whether it might be better not to bring up the dialog box and
whether it might get faster, but these are secondary issues. I'll be
posting a request for another shortcut (again having to do with appearance
/ accessibility) in another message. -Eustace

Read previous post

Jon

Jon said:
Hi Eustace

Sorry for the delay. Was enjoying my weekend :)

Let me know if this works ok [Script below]

NB Put in your 2 theme paths, as previously [lines 2 & 3]. Watch for
wordwrap - all on one line.

NB Remove the last 2 lines if you don't want the information popup, or
modify it with a suitable message of your own choosing . I often find a
reminder message useful, so I've included it.

Because of wordwrap, I'll try and attach the full script to a follow up
message.

For any other modifications you may think of, I would suggest googling
for "Windows Script Host" and vbscript and you will be able to tweak it
further to your heart's desire. Even a small amount of knowledge can go
a long way.

Alternatively, if you, or anyone else, have any suggestions for a more
sophisticated program, then you can send me an email [reply to address
is genuine].


Jon


'****************************************************************************
Set WshShell = WScript.CreateObject("WScript.shell")

Theme1="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME1.theme"
Theme2="C:\Documents and Settings\USERNAMEHERE\My
Documents\Themes\NAMEOFTHEME2.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\Plus!\Themes\Current\"
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}"

'Toggle message
WshShell.Popup thememessage & " theme applied" , 3,"Theme Toggler",64

'****************************************************************************


I have created 2 files to switch between 2 themes, according to earlier
directions from Jon. The one is:

======================================
Set WshShell = WScript.CreateObject("WScript.shell")
Theme = "C:\Documents and Settings\Eustace\My Documents\My White
Theme.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 other is similar except that it refers to My Blue Theme.theme.

So far so good. I have put shortcuts to the 2 files in the Quick Launch
so I can switch the themes from there. I am wondering, however, whether
instead of 2 shortcuts I could have only 1 file that would:

1. detect the current theme
2. if the current theme is not My White Theme apply My White Theme
3. if the current theme is My White Theme apply My Blue Theme

That shouldn't be too difficult, or am I asking too much, Jon?

Thanks,

Eustace
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top