Jump to content

Windos11 context menu style


 Share

Go to solution Solved by Andreik,

Recommended Posts

hello all

I can use the same commands that I entered in the .cmd file, without creating the WinStyle.cmd file

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinApi.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Win11 Style", 251, 97, -1, -1)
GUISetBkColor(0xFFFFFF)
$BtnOldStyle = GUICtrlCreateButton("Old Style", 14, 16, 100, 30)
GUICtrlSetFont(-1, 10, 400, 0, "MS UI Gothic")
$BtnDefaultStyle = GUICtrlCreateButton("Default", 136, 16, 100, 30)
GUICtrlSetFont(-1, 10, 400, 0, "MS UI Gothic")
$BtnRefresh = GUICtrlCreateButton("", 210, 56, 40, 40, $BS_ICON)
GUICtrlSetTip(-1, "Restart Explorer")
GUICtrlSetImage(-1, "shell32.dll", -239)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
Case $BtnOldStyle
    $file = fileopen (@Tempdir & "\WinStyle.cmd" , 2) 
    filewrite ($file , "@echo off" & @CRLF) 
    filewrite ($file , "reg add ""HKCU\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"" /ve /f" & @CRLF)
    filewrite ($file , "taskkill /im explorer.exe /f" & @CRLF)
    filewrite ($file , "explorer.exe")
    fileclose($file)
    Run(@TempDir & "\WinStyle.cmd", @TempDir, @SW_HIDE)
    MsgBox(BitOr($MB_ICONINFORMATION, $MB_TASKMODAL), "Message", "Old Style Ok!", 3)
    Case $BtnDefaultStyle
    $file = fileopen (@Tempdir & "\WinStyle.cmd" , 2) 
    filewrite ($file , "@echo off" & @CRLF) 
    filewrite ($file , "reg delete ""HKCU\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"" /f" & @CRLF) 
    fileclose($file)
    Run(@TempDir & "\WinStyle.cmd", @TempDir, @SW_HIDE) 
    MsgBox(BitOr($MB_ICONINFORMATION, $MB_TASKMODAL), "Message", "Default Style OK!", 2)
    
    Case $BtnRefresh
            RunWait(@ComSpec & " /c " & "taskkill /f /im explorer.exe", "", @SW_HIDE) 
            RunWait(@ComSpec & " /c " & "start " & @WindowsDir & "\explorer.exe", "", @SW_HIDE) 
    EndSwitch
WEnd

 

Link to comment
Share on other sites

  • Solution

You can use Run() or _RunDOS() functions to run the commands directly or even better use Registry functions to add/delete registries (RegWrite, RegDelete) since this is what your cmd file does. Check out these functions in help file.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

43 minutes ago, Andreik said:

You can use Run() or _RunDOS() functions to run the commands directly or even better use Registry functions to add/delete registries (RegWrite, RegDelete) since this is what your cmd file does. Check out these functions in help file.

I did not think about it... o my good! 😮

Link to comment
Share on other sites

my solution is:

;AL72
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinApi.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Win11 Style", 251, 97, -1, -1)
GUISetBkColor(0xFFFFFF)
$BtnOldStyle = GUICtrlCreateButton("Old Style", 14, 16, 100, 30)
GUICtrlSetFont(-1, 10, 400, 0, "MS UI Gothic")
$BtnDefaultStyle = GUICtrlCreateButton("Default", 136, 16, 100, 30)
GUICtrlSetFont(-1, 10, 400, 0, "MS UI Gothic")
$BtnRefresh = GUICtrlCreateButton("", 210, 56, 40, 40, $BS_ICON)
GUICtrlSetTip(-1, "Restart Explorer")
GUICtrlSetImage(-1, "shell32.dll", -239)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
Case $BtnOldStyle
RunWait(@ComSpec & " /c " & "reg add ""HKCU\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"" /ve /f","", @SW_HIDE) 
RunWait(@ComSpec & " /c " & "taskkill /f /im explorer.exe", "", @SW_HIDE) 
RunWait(@ComSpec & " /c " & "start " & @WindowsDir & "\explorer.exe", "", @SW_HIDE) 

Case $BtnDefaultStyle
RunWait(@ComSpec & " /c " & "reg delete ""HKCU\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"" /f","", @SW_HIDE) 
RunWait(@ComSpec & " /c " & "taskkill /f /im explorer.exe", "", @SW_HIDE) 
RunWait(@ComSpec & " /c " & "start " & @WindowsDir & "\explorer.exe", "", @SW_HIDE) 

Case $BtnRefresh
RunWait(@ComSpec & " /c " & "taskkill /f /im explorer.exe", "", @SW_HIDE) 
RunWait(@ComSpec & " /c " & "start " & @WindowsDir & "\explorer.exe", "", @SW_HIDE) 

    EndSwitch
WEnd

 

Edited by Alfonso72
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...