Bonjour.
Je cherche ceci :
lister tous les dossiers actifs / ouverts,
afin de les relancer quand je tuerais le processus Explorer.exe,
pour continuer un script déjà bien avancé.
Pour info : le script de départ
me permet de désactiver ou de réactiver Cortana (la recherche WEB).
- Si je désactive Cortana, la recherche ne se fera que sur le PC.
- Si je réactive Cortana, la recherche se fera aussi bien sur le web que sur le PC.
Et bien entendu, pour que les modifications soient prisent en compte, il faut :
- Soit redémarrer ou se déconnecter de la sessions en cours.
- Soit Fermer explorer.exe et le relancer.
Je préfère bien sur la
solution n°2.
Le script fonctionne...
Mais quand on tue le processus explorer.exe et qu'on le relance,
les dossiers auparavant ouverts se ferment mais se relancent pas.
Je cherche donc un moyen de lister, avant le redémarrage d'explorer.exe,
tous les dossiers ouverts.
Afin que je puisse
les ré-ouvrir par la suite.
Sauf que je dois m'y prendre comme un manche :
mes recherches n'aboutissent pas, aussi bien en français qu'en anglais....
Seul ce topic m'avait l'air intéressant :
https://www.autoitscript.com/forum/topi ... -explorer/
j'ai testé ce script donc :
► Afficher le texte
#include "_AutomatingWindowsExplorer.au3"#include <Array.au3>Opt( "MustDeclareVars", 1 )Example
()Func Example
() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser
( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces
() ; Get all folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aFolders = GetFolders
(false,True) _ArrayDisplay( $aFolders, "All folders") ; Get selected folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 );~ $aFolders = GetFolders( True );~ _ArrayDisplay( $aFolders, "Selected folders" )EndFunc
Sauf que ce script
ne détecte que le dossier actuel et ses sous-dossiers.
Alors que je cherche à
détecter tous les dossiers actifs, sans les sous-dossiers.
Ensuite, je me suis dis : et si je
listais toutes les fenêtres (WinList),
avec la condition suivante :
si la fenêtre détectée est un dossier, copier le chemin.
Sauf que c'est bien beau de l'écrire, mais pour le faire, c'est une autre paire de manche. Je pensais faire avec WinGetState, mais je me suis ravisé quand j'ai lu l'aide. xD
Pouvez-vous m'aider svp ?
Je vous met les scripts qui me servent pour Cortana :
► Afficher le texteActiver Cortana
#RequireAdminRegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana"); Restart Explorer$Kernel32 = DllOpen("kernel32.dll")$hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe'))DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 0)DllClose($Kernel32)
► Afficher le texteDésactiver Cortana
#RequireAdminRegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", "REG_DWORD", 0); Restart Explorer$Kernel32 = DllOpen("kernel32.dll")$hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe'))DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 0)DllClose($Kernel32)
► Afficher le texteActiver/Désactiver Cortana (GUI)
;~ A faire : fermer & relancer explorer.exe sans fermer les dossiers#RequireAdmin#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>Global $Form1 = GUICreate("Form1", 615, 437, 192, 124)$desactiver = GUICtrlCreateButton("désactiver Cortana (WEB)", 5, 5, 150, 20)$activer = GUICtrlCreateButton("(ré)activer Cortana (WEB)", 160, 5, 150, 20)_Etat_Cortana
()GUISetState(@SW_SHOW)While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $desactiver _Action_Cortana
(0) Case $activer _Action_Cortana
(1) EndSwitchWEndFunc _Etat_Cortana
() $AllowCortana = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana") If $AllowCortana = "0" Then GUICtrlSetState($desactiver, $GUI_DISABLE) GUICtrlSetState($activer, $GUI_ENABLE) Else GUICtrlSetState($desactiver, $GUI_ENABLE) GUICtrlSetState($activer, $GUI_DISABLE) EndIfEndFunc ;==>_Etat_CortanaFunc _Action_Cortana
($ch) If $ch = 1 Then RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana") If $ch = 0 Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", "REG_DWORD", 0) $Kernel32 = DllOpen("kernel32.dll") $hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe')) DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 0) DllClose($Kernel32) _Etat_Cortana
()EndFunc ;==>_Action_Cortana
► Afficher le texteActiver/désactiver Cortana (Systray)
;~ A faire : fermer & relancer explorer.exe sans fermer les dossiers#RequireAdmin#include <TrayConstants.au3>#include <GUIConstantsEx.au3>Opt("TrayMenuMode", 3)Local $Cortana_desactivation = TrayCreateItem("Désactiver Cortana (WEB)")Local $Cortana_activation = TrayCreateItem("Activer Cortana (WEB)")Local $SystrayEXIT = TrayCreateItem("Quitter")_Etat_Cortana
()While 1 Switch TrayGetMsg() Case $SystrayEXIT Exit Case $Cortana_desactivation _Action_Cortana
(0) Case $Cortana_activation _Action_Cortana
(1) EndSwitchWEndFunc _Action_Cortana
($ch) If $ch = 1 Then RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana") If $ch = 0 Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", "REG_DWORD", 0) $Kernel32 = DllOpen("kernel32.dll") $hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe')) DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 0) DllClose($Kernel32) _Etat_Cortana
()EndFunc ;==>_Action_CortanaFunc _Etat_Cortana
() $AllowCortana = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana") If $AllowCortana = "0" Then TrayItemSetState($Cortana_desactivation, $GUI_DISABLE) TrayItemSetState($Cortana_activation, $GUI_ENABLE) Else TrayItemSetState($Cortana_desactivation, $GUI_ENABLE) TrayItemSetState($Cortana_activation, $GUI_DISABLE) EndIfEndFunc ;==>_Etat_Cortana
► Afficher le texteActiver/Désactiver Cortana directement (Pas de Gui)
#RequireAdmin$AllowCortana = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana")If $AllowCortana = "0" Then _Action_Cortana
(1)Else _Action_Cortana
(0)EndIfFunc _Action_Cortana
($ch) If $ch = 1 Then RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana") If $ch = 0 Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", "REG_DWORD", 0) $Kernel32 = DllOpen("kernel32.dll") $hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe')) DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 0) DllClose($Kernel32)EndFunc ;==>_Action_Cortana
Merci à tous pour vos pistes !
A la prochaine !
