1. Welcome Guest! In order to create a new topic or reply to an existing one, you must register first. It is easy and free. Click here to sign up now!.
    Dismiss Notice

Code to toggle 2 themes

Discussion in 'Windows Vista' started by Eustace, Jun 18, 2009.

  1. Eustace

    Eustace Guest

    A nice guy once provided me the following code that toggles 2 Windows XP
    themes:

    ============================================

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

    Theme1="C:\My Stuff\My Files\My Themes\My Vista Theme.theme"
    Theme2="C:\My Stuff\My Files\My Themes\My Dark Theme.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}"

    ============================================

    I had put it in a file and had a shortcut to it in the Quick Launch, so
    I could easily change between these 2 themes. You see, I prefer white
    text on dark background, and some application dialogs do not specify
    both colors...

    I tried to run the above code in Vista, but unfortunately, though it
    does bring up the themes dialog, it does not change the themes
    automatically.

    How can I make it change the themes automatically in Vista?

    Thanks,

    emf

    --
    It ain't THAT, babe! - A radical reinterpretation
     
  2. Jon

    Jon Guest

    Hi Eustace

    Try using the line

    activated = WshShell.AppActivate("Theme Settings")

    in place of the current line

    activated = WshShell.AppActivate("Display Properties")

    The title / caption of the themes dialog has changed with Vista, hence the
    need for the change.

    --
    Jon



    "Eustace" <emfril@gmail.com> wrote in message
    news:uw2lWO$7JHA.1712@TK2MSFTNGP03.phx.gbl...<!--coloro:blue--><span style="color:blue <!--/coloro-->
    >A nice guy once provided me the following code that toggles 2 Windows XP
    >themes:
    >
    > ============================================
    >
    > Set WshShell = WScript.CreateObject("WScript.shell")
    >
    > Theme1="C:My StuffMy FilesMy ThemesMy Vista Theme.theme"
    > Theme2="C:My StuffMy FilesMy ThemesMy Dark Theme.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_USERSoftwareMicrosoftPlus!ThemesCurrent"
    > 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}"
    >
    > ============================================
    >
    > I had put it in a file and had a shortcut to it in the Quick Launch, so I
    > could easily change between these 2 themes. You see, I prefer white text
    > on dark background, and some application dialogs do not specify both
    > colors...
    >
    > I tried to run the above code in Vista, but unfortunately, though it does
    > bring up the themes dialog, it does not change the themes automatically.
    >
    > How can I make it change the themes automatically in Vista?
    >
    > Thanks,
    >
    > emf
    >
    > --
    > It ain't THAT, babe! - A radical reinterpretation
    > <!--colorc--><!--/colorc-->
     

Share This Page