Jump to content

Convert Vbscript to set visual effects to AutoIt syntax


ffdshow
 Share

Recommended Posts

Hello,

I found the next vbscript which allows you to set all of Windows' visual effects as though the
' sysdm.cpl applet.

I used VBScript to AutoIt Converter v0.4 for conversion to AutoIt syntax, but I got several errors on AutoIt script execution. Maybe someone can fix it.

The VBScript works fine, some tweaks need Windows logoff or computer restart so can be applied.

VBScript source

' =============== VISUAL EFFECTS =============== 
A = "0" ' Animate controls and elements inside windows 
B = "0" ' Fade or slide menu's into view 
C = "0" ' Fade or slide ToolTips into view 
D = "0" ' Fade out menu items after clicking 
E = "0" ' Show shadows under mouse pointer 
F = "0" ' Show shadows under windows 
G = "0" ' Slide open combo boxes 
H = "0" ' Smooth-scroll list boxes 
I = "1" ' Use visual styles on windows and buttons 
J = "1" ' Show window contents while dragging 
K = "1" ' Smooth edges of screen fonts 
L = "0" ' Animate windows when minimizing and maximizing 
M = "1" ' Show translucent selection rectangle 
N = "1" ' Use drop shadows for icon labels on the desktop 
O = "0" ' Animations in the taskbar and Start Menu 
P = "0" ' Show thumbnails instead of icons 
Q = "1" ' Enable desktop composition 
R = "0" ' Enable transparent glass 
S = "0" ' Enable Aero Peek 
T = "0" ' Save taskbar thumbnail previews 
' ============================================== 
 
UPM_a = Array(_ 
Array("1","0","0","1", H , G , B ,"0"),_ 
Array("0","0", E ,"1", C , D ,"1","0"),_ 
Array("0","0","0","0","0", F , I ,"1"),_ 
Array("1","0","0","0","0","0","0","0"),_ 
Array("0","0","0","1","0","0", A ,"0"),_ 
Array("0","0","0","0","0","0","0","0"),_ 
Array("0","0","0","0","0","0","0","0"),_ 
Array("0","0","0","0","0","0","0","0")_ 
) 
UPM_b = Array(Empty, Empty, Empty, Empty, Empty, Empty, Empty, Empty) 
Dim i 
For i = 0 To UBound(UPM_a) 
  UPM_b(i) = CStr(BinToDec(UPM_a(i))) 
Next 
 
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") 
objReg.SetBinaryValue &H80000001, "Control Panel\Desktop", "UserPreferencesMask", UPM_b 
objReg.SetStringValue &H80000001, "Control Panel\Desktop", "DragFullWindows", IIf(J = "1", "1", "0") 
objReg.SetStringValue &H80000001, "Control Panel\Desktop", "FontSmoothing", IIf(K = "1", "2", "0") 
objReg.SetStringValue &H80000001, "Control Panel\Desktop\WindowMetrics", "MinAnimate", IIf(L = "1", "1", "0") 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewAlphaSelect", IIf(M = "1", 1, 0) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewShadow", IIf(N = "1", 1, 0) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarAnimations", IIf(O = "1", 1, 0) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "IconsOnly", IIf(P = "1", 0, 1) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\DWM", "Composition", IIf(Q = "1", 1, 0) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\DWM", "CompositionPolicy", IIf(Q = "1", 2, 0) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\DWM", "ColorizationOpaqueBlend", IIf(R = "1", 0, 1) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\DWM", "EnableAeroPeek", IIf(S = "1", 1, 0) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\DWM", "AlwaysHibernateThumbnails", IIf(T = "1", 1, 0) 
objReg.SetDWORDValue &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting", 3 
 
Function BinToDec(arrBin()) 
  Dim r, i 
  r = 0 
  For i = UBound(arrBin) To 0 Step -1 
    If arrBin(i) = "1" Then r = r + (2 ^ (UBound(arrBin) - i)) 
  Next 
  BinToDec = r 
End Function 
 
Function IIf(Expression, TruePart, FalsePart) 
  If Expression = True Then 
    If IsObject(TruePart) Then Set IIf = TruePart Else IIf = TruePart 
  Else 
    If IsObject(FalsePart) Then Set IIf = FalsePart Else IIf = FalsePart 
  End If 
End Function

Thanks!

Link to comment
Share on other sites

Here an untested 1:1 conversion:

; 1:1 converted from http://gallery.technet.microsoft.com/scriptcenter/Vbscript-to-set-visual-cd211be9 by UEZ 2013

; =============== VISUAL EFFECTS ===============
$A = "0" ; Animate controls and elements inside windows
$B = "0" ; Fade or slide menu;s into view
$C = "0" ; Fade or slide ToolTips into view
$D = "0" ; Fade out menu items after clicking
$E = "0" ; Show shadows under mouse pointer
$F = "0" ; Show shadows under windows
$G = "0" ; Slide open combo boxes
$H = "0" ; Smooth-scroll list boxes
$I = "1" ; Use visual styles on windows and buttons
$J = "1" ; Show window contents while dragging
$K = "1" ; Smooth edges of screen fonts
$L = "0" ; Animate windows when minimizing and maximizing
$M = "1" ; Show translucent selection rectangle
$N = "1" ; Use drop shadows for icon labels on the desktop
$O = "0" ; Animations in the taskbar and Start Menu
$P = "0" ; Show thumbnails instead of icons
$Q = "1" ; Enable desktop composition
$R = "0" ; Enable transparent glass
$S = "0" ; Enable Aero Peek
$T = "0" ; Save taskbar thumbnail previews
; ==============================================

Global $UPM_a[8], $UPM_b[8], $i, $bBin
Global $UPM_a0[8] = ["1","0","0","1", $H , $G , $B ,"0"]
Global $UPM_a1[8] = ["0","0", $E ,"1", $C , $D ,"1","0"]
Global $UPM_a2[8] = ["0","0","0","0","0", $F , $I ,"1"]
Global $UPM_a3[8] = ["1","0","0","0","0","0","0","0"]
Global $UPM_a4[8] = ["0","0","0","1","0","0", $A ,"0"]
Global $UPM_a5[8] = ["0","0","0","0","0","0","0","0"]
Global $UPM_a6[8] = ["0","0","0","0","0","0","0","0"]
Global $UPM_a7[8] = ["0","0","0","0","0","0","0","0"]
For $i = 0 To UBound($UPM_a) - 1
    $UPM_a[$i] = Execute("$UPM_a" & $i)
Next

For $i = 0 To UBound($UPM_a) - 1
    $UPM_b[$i] = String(BinToDec($UPM_a[$i]))
    $bBin &= Hex($UPM_b[$i], 2)
Next

RegWrite("HKCU\Control Panel\Desktop", "UserPreferencesMask", "REG_BINARY", Binary("0x" & $bBin))
RegWrite("HKCU\Control Panel\Desktop", "DragFullWindows", "REG_SZ", IIf($J = "1", "1", "0"))
RegWrite("HKCU\Control Panel\Desktop", "FontSmoothing", "REG_SZ", IIf($K = "1", "2", "0"))
RegWrite("HKCU\Control Panel\Desktop\WindowMetrics", "MinAnimate", "REG_SZ", IIf($L = "1", "1", "0"))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewAlphaSelect", "REG_DWORD", IIf($M = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewShadow", "REG_DWORD", IIf($N = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarAnimations", "REG_DWORD", IIf($O = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "IconsOnly", "REG_DWORD", IIf($P = "1", 0, 1))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "Composition", "REG_DWORD", IIf($Q = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "CompositionPolicy", "REG_DWORD", IIf($Q = "1", 2, 0))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "ColorizationOpaqueBlend", "REG_DWORD", IIf($R = "1", 0, 1))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "EnableAeroPeek", "REG_DWORD", IIf($S = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "AlwaysHibernateThumbnails", "REG_DWORD", IIf($T = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting", "REG_DWORD", 3)


Func BinToDec($arrBin)
    Local $r = "0", $i, $iUB = UBound($arrBin) - 1
    For $i = $iUB To 0 Step - 1
        If $arrBin[$i] = "1" Then $r += 2 ^ ($iUB - $i)
    Next
    Return $r
EndFunc

Func IIf($Expression, $TruePart, $FalsePart)
    If $Expression Then Return $TruePart
    Return $FalsePart
EndFunc
There is enough room for code optimization!

Br,

UEZ

Edit: forgot the reg type for the last regwrite line

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Can you compare the values which is written by AutoIt with VBS?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Can you compare the values which is written by AutoIt with VBS?

Br,

UEZ

Sorry, I didn't verified your script, just choosed the tweaks from variables and run.

This line (which is the most important) from your script was the problem:

RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting", 3)

The working script is this:

; 1:1 converted from http://gallery.technet.microsoft.com/scriptcenter/Vbscript-to-set-visual-cd211be9 by UEZ 2013

; =============== VISUAL EFFECTS ===============
$A = "0" ; Animate controls and elements inside windows
$B = "0" ; Fade or slide menu;s into view
$C = "0" ; Fade or slide ToolTips into view
$D = "0" ; Fade out menu items after clicking
$E = "0" ; Show shadows under mouse pointer
$F = "0" ; Show shadows under windows
$G = "0" ; Slide open combo boxes
$H = "0" ; Smooth-scroll list boxes
$I = "1" ; Use visual styles on windows and buttons
$J = "1" ; Show window contents while dragging
$K = "1" ; Smooth edges of screen fonts
$L = "0" ; Animate windows when minimizing and maximizing
$M = "1" ; Show translucent selection rectangle
$N = "1" ; Use drop shadows for icon labels on the desktop
$O = "0" ; Animations in the taskbar and Start Menu
$P = "0" ; Show thumbnails instead of icons
$Q = "1" ; Enable desktop composition
$R = "0" ; Enable transparent glass
$S = "0" ; Enable Aero Peek
$T = "0" ; Save taskbar thumbnail previews
; ==============================================

Global $UPM_a[8], $UPM_b[8], $i, $bBin
Global $UPM_a0[8] = ["1","0","0","1", $H , $G , $B ,"0"]
Global $UPM_a1[8] = ["0","0", $E ,"1", $C , $D ,"1","0"]
Global $UPM_a2[8] = ["0","0","0","0","0", $F , $I ,"1"]
Global $UPM_a3[8] = ["1","0","0","0","0","0","0","0"]
Global $UPM_a4[8] = ["0","0","0","1","0","0", $A ,"0"]
Global $UPM_a5[8] = ["0","0","0","0","0","0","0","0"]
Global $UPM_a6[8] = ["0","0","0","0","0","0","0","0"]
Global $UPM_a7[8] = ["0","0","0","0","0","0","0","0"]
For $i = 0 To UBound($UPM_a) - 1
    $UPM_a[$i] = Execute("$UPM_a" & $i)
Next

For $i = 0 To UBound($UPM_a) - 1
    $UPM_b[$i] = String(BinToDec($UPM_a[$i]))
    $bBin &= Hex($UPM_b[$i], 2)
Next

RegWrite("HKCU\Control Panel\Desktop", "UserPreferencesMask", "REG_BINARY", Binary("0x" & $bBin))
RegWrite("HKCU\Control Panel\Desktop", "DragFullWindows", "REG_SZ", IIf($J = "1", "1", "0"))
RegWrite("HKCU\Control Panel\Desktop", "FontSmoothing", "REG_SZ", IIf($K = "1", "2", "0"))
RegWrite("HKCU\Control Panel\Desktop\WindowMetrics", "MinAnimate", "REG_SZ", IIf($L = "1", "1", "0"))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewAlphaSelect", "REG_DWORD", IIf($M = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewShadow", "REG_DWORD", IIf($N = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarAnimations", "REG_DWORD", IIf($O = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "IconsOnly", "REG_DWORD", IIf($P = "1", 0, 1))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "Composition", "REG_DWORD", IIf($Q = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "CompositionPolicy", "REG_DWORD", IIf($Q = "1", 2, 0))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "ColorizationOpaqueBlend", "REG_DWORD", IIf($R = "1", 0, 1))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "EnableAeroPeek", "REG_DWORD", IIf($S = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\DWM", "AlwaysHibernateThumbnails", "REG_DWORD", IIf($T = "1", 1, 0))
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting", "REG_DWORD", 3)

Func BinToDec($arrBin)
    Local $r = "0", $i, $iUB = UBound($arrBin) - 1
    For $i = $iUB To 0 Step - 1
        If $arrBin[$i] = "1" Then $r += 2 ^ ($iUB - $i)
    Next
    Return $r
EndFunc

Func IIf($Expression, $TruePart, $FalsePart)
    If $Expression Then Return $TruePart
    Return $FalsePart
EndFunc

Thanks!

Edited by ffdshow
Link to comment
Share on other sites

@UEZ - I don't understand this (the use of the execute stmt)...

For $i = 0 To UBound($UPM_a) - 1
    $UPM_a[$i] = Execute("$UPM_a" & $i)
Next

Can you explain it please?

Thanks,

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Sure,

the VBS code adds arrays to the master array $UPM_a (arrays in an array) and because of my lazyness I used the for/next loop to save the arrays $UPM_a0 to $UPM_a8 into the master array.

The for/next loop is the same as

$UPM_a[0] = $UPM_a0
$UPM_a[1] = $UPM_a1
...
$UPM_a[7] = $UPM_a7

Clear now?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Eval is not working because of the array pointers which are not visible to eval whereas Execute "runs" the variable and saves the array pointer.

 

Example:

Global $aMaster[2]
Global $aArray1[1] = ["Array1"]
Global $aArray2[1] = ["Array2"]
For $i = 1 To 2
    $aMaster[$i - 1] = Execute("$aArray" & $i)
;~  $aMaster[$i - 1] = Eval("aArray" & $i)
Next
ConsoleWrite("$aMaster[0] = " & $aMaster[0] & @LF)

$a1 = $aMaster[0]
$a2 = $aMaster[1]
ConsoleWrite($a1[0] & @LF)
ConsoleWrite($a2[0] & @LF)

Just replace Execute with Eval to "see" the difference.

 

Br,

UEZ

Edit: Eval is also working.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ - I change it to this and get the same results...

Global $aMaster[2]
Global $aArray1[1] = ["Array1"]
Global $aArray2[1] = ["Array2"]
For $i = 1 To 2
    $aMaster[$i - 1] = Eval("aArray" & $i)
Next
ConsoleWrite("$aMaster[0] = " & $aMaster[0] & @LF)

$a1 = $aMaster[0]
$a2 = $aMaster[1]
ConsoleWrite($a1[0] & @LF)
ConsoleWrite($a2[0] & @LF)

I get your use of the execute, however, thanks.

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Yes, Eval is also working. I've tested Eval("$aArray" & $i) and that's not working.  :>

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...