Как применить определенную тему к Windows 7, если она не применяется? - PullRequest
1 голос
/ 17 февраля 2020

Вот немного измененный код отсюда: VB Скрипт для применения определенной Windows Тема

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""%windir%\Resources\Ease of Access Themes\basic.theme"""
Do Until GetWnd(oWnd) 
    WScript.Sleep 10
Loop
'sLocationName = oWnd.LocationName ' debug
oWnd.Quit 
'WScript.Echo sLocationName & " Closed" ' debug


Function GetWnd(oShellWnd)
    On Error Resume Next
    GetWnd = False
    For Each oShellWnd In CreateObject("Shell.Application").Windows
        With oShellWnd
            If InStr(LCase(TypeName(.Document)), "ishell") = 0 Then 
            Else
                If InStr(.Document.Folder.Self.Path, "::{26EE0668-A00A-44D7-9371-BEB064C98683}") = 0 Then
                Else
                    GetWnd = True
                    Exit For
                End If
            End If
        End With
    Next
End Function

Мне нужно добавить условие, которое проверяет активную тему, и если это not% windir% \ Resources \ Ease of Access Themes \ basi c .theme, тогда весь код выше выполняется. Должен работать на Windows 7. Есть предложения?

1 Ответ

0 голосов
/ 21 февраля 2020

Ну, я написал это так, как мне нужно. Не стесняйтесь использовать. Отладочные сообщения не комментируются. Скрипт работает для Windows 7, проверяет текущую тему в реестре и, если она не является базовой c .theme, применяет ее и закрывает окно персонализации. Не стесняйтесь использовать.

On Error Resume Next
Dim currentTheme,ReadTheme
Set WshShell = WScript.CreateObject("WScript.Shell") 
currentTheme = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme"
ReadTheme = WSHShell.RegRead(currentTheme)
'---Reading Reg Values
WSHShell.RegRead(currentTheme)
'---Echo Values for debug
'WScript.Echo WshShell.RegRead(currentTheme)

If Err Then
'---Applying theme if error occured
ApplyBasicTheme()   
Else
    If ReadTheme = "C:\Windows\resources\Ease of Access Themes\basic.theme" Then
    WScript.Echo "It's basic" & WshShell.RegRead(currentTheme) & ", nothing to do" ' debug
    Else
    ApplyBasicTheme()       
    End If
End If

Function ApplyBasicTheme()
    Msgbox "Not basic" & WshShell.RegRead(currentTheme) & ", changing", vbExclamation ' debug
    WshShell.Run "rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""%windir%\Resources\Ease of Access Themes\basic.theme"""
    Do Until GetWnd(oWnd) ' Wait until Personalisation Window appears
        WScript.Sleep 10
    Loop
    'sLocationName = oWnd.LocationName ' debug
    oWnd.Quit ' Close Personalisation Window
    'WScript.Echo sLocationName & " Closed" ' debug
End function

Function GetWnd(oShellWnd)
    On Error Resume Next
    GetWnd = False
        For Each oShellWnd In CreateObject("Shell.Application").Windows
            With oShellWnd
            If InStr(LCase(TypeName(.Document)), "ishell") = 0 Then ' is explorer window, but not internet explorer
            Else
                If InStr(.Document.Folder.Self.Path, "::{26EE0668-A00A-44D7-9371-BEB064C98683}") = 0 Then ' any control panel window
            Else
            GetWnd = True
        Exit For
                End If
            End If
            End With
    Next
End Function
WScript.Quit
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...