fucooca Posted August 11 Posted August 11 hi sorry for disturb I have a code that changes the Windows 11 right-click menu style back to Windows 10, then kills explorer and is supposed to relaunch it, but it doesn't relaunch it—it opens a folder instead. expandcollapse popup; AutoIt - Gestione Menu Contestuale Windows 10/11 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Crea la finestra $hGUI = GUICreate("Gestione Menu Contestuale", 380, 90, -1, -1, $WS_SYSMENU) $btnON = GUICtrlCreateButton("Tasto DX Win10 Style ON", 10, 20, 160, 50) $btnOFF = GUICtrlCreateButton("Tasto DX Win10 Style OFF", 200, 20, 160, 50) ; Aggiorna stato pulsanti UpdateButtons() GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btnON ; Attiva stile Windows 10 RunWait(@ComSpec & ' /c reg add "HKCU\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /ve /f', "", @SW_HIDE) RestartExplorer() UpdateButtons() Case $btnOFF ; Ripristina stile Windows 11 RunWait(@ComSpec & ' /c reg delete "HKCU\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f', "", @SW_HIDE) RestartExplorer() UpdateButtons() EndSwitch WEnd ; Funzione per verificare se lo stile Windows 10 è attivo Func CheckWin10Style() Return RegRead("HKCU\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32", "") <> "" EndFunc ; Funzione per aggiornare lo stato dei pulsanti Func UpdateButtons() If CheckWin10Style() Then GUICtrlSetState($btnON, $GUI_DISABLE) GUICtrlSetState($btnOFF, $GUI_ENABLE) Else GUICtrlSetState($btnON, $GUI_ENABLE) GUICtrlSetState($btnOFF, $GUI_DISABLE) EndIf EndFunc ; FUNZIONE CORRETTA PER RIAVVIARE LA SHELL Func RestartExplorer() ; 1. Uccidi il processo explorer.exe (la shell) RunWait(@ComSpec & " /c taskkill /f /im explorer.exe", "", @SW_HIDE) ; Breve pausa per assicurarsi che il processo sia terminato Sleep(1000) ; 2. Riavvia explorer.exe come shell usando ShellExecute ; Questo è il metodo che funziona per ripristinare la taskbar e il desktop. ShellExecute("explorer.exe") ; Attendi che la shell si riavvii completamente Sleep(1500) ; Riporta la finestra dell'app in primo piano WinActivate($hGUI) WinSetState($hGUI, "", @SW_RESTORE) EndFunc anyone can help me ? thanks
Developers Jos Posted August 11 Developers Posted August 11 1 hour ago, fucooca said: but it doesn't relaunch it—it opens a folder instead. isn't opening a folder the same as relaunching? I assume you what explorer to start without showing the window? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
fucooca Posted August 11 Author Posted August 11 37 minutes ago, Jos said: isn't opening a folder the same as relaunching? I assume you what explorer to start without showing the window? nono if you open cmd and run taskkill explorer closs all explorer all folder desktop image and start bar , for re run all you must write always in cmd explorer and it restart regular all but when i try to send a command , explorer i dont know why open a folder , i suppose becase is thesame command but i think exist amode some option for rerun a service explorer and not only folder?
bladem2003 Posted August 11 Posted August 11 this works for me Func _Restart_Explorer() Local $ifailure = 100, $zfailure = 100, $rPID = 0, $iExplorerPath = @WindowsDir & "\Explorer.exe" _WinAPI_ShellChangeNotify($shcne_AssocChanged, 0, 0, 0) ; Save icon positions Local $hSystray = _WinAPI_FindWindow("Shell_TrayWnd", "") _SendMessage($hSystray, 1460, 0, 0) ; Close the Explorer shell gracefully While ProcessExists("Explorer.exe") ; Try Close the Explorer Sleep(10) $ifailure -= ProcessClose("Explorer.exe") ? 0 : 1 If $ifailure < 1 Then Return SetError(1, 0, 0) WEnd While (Not ProcessExists("Explorer.exe")) ; Start the Explorer If Not FileExists($iExplorerPath) Then Return SetError(-1, 0, 0) Sleep(500) $rPID = ShellExecute($iExplorerPath) $zfailure -= $rPID ? 0 : 1 If $zfailure < 1 Then Return SetError(2, 0, 0) WEnd Return $rPID EndFunc ;==>_Restart_Explorer argumentum 1
fucooca Posted August 11 Author Posted August 11 2 hours ago, bladem2003 said: this works for me Func _Restart_Explorer() Local $ifailure = 100, $zfailure = 100, $rPID = 0, $iExplorerPath = @WindowsDir & "\Explorer.exe" _WinAPI_ShellChangeNotify($shcne_AssocChanged, 0, 0, 0) ; Save icon positions Local $hSystray = _WinAPI_FindWindow("Shell_TrayWnd", "") _SendMessage($hSystray, 1460, 0, 0) ; Close the Explorer shell gracefully While ProcessExists("Explorer.exe") ; Try Close the Explorer Sleep(10) $ifailure -= ProcessClose("Explorer.exe") ? 0 : 1 If $ifailure < 1 Then Return SetError(1, 0, 0) WEnd While (Not ProcessExists("Explorer.exe")) ; Start the Explorer If Not FileExists($iExplorerPath) Then Return SetError(-1, 0, 0) Sleep(500) $rPID = ShellExecute($iExplorerPath) $zfailure -= $rPID ? 0 : 1 If $zfailure < 1 Then Return SetError(2, 0, 0) WEnd Return $rPID EndFunc ;==>_Restart_Explorer MYTH work now thanks so much
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now