ioa747 Posted January 20, 2023 Posted January 20, 2023 (edited) is there a more efficient way to enumerating all open folders? I did this but i don't know if the $sPath = StringTrimLeft($sPath[15], 9) is always in the same position #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include <WinAPISysWin.au3> #include <Array.au3> Local $Test = Example() _ArrayDisplay($Test, "$Test") Func Example() ; CabinetWClass Local $aWindows, $i, $sPath, $index = 0 Local $CabinetW[1][2] = [["hWnd", "Path"]] $aWindows = _WinAPI_EnumWindowsTop() For $i = 1 To $aWindows[0][0] If $aWindows[$i][1] = "CabinetWClass" Then ReDim $CabinetW[UBound($CabinetW) + 1][2] $index += 1 $CabinetW[0][0] = $index $sPath = WinGetText($aWindows[$i][0]) $sPath = StringSplit($sPath, @LF) $sPath = StringTrimLeft($sPath[15], 9) ; trim 'Address: ' $CabinetW[$index][0] = $aWindows[$i][0] $CabinetW[$index][1] = $sPath EndIf Next Return $CabinetW EndFunc ;==>Example Thanks! Edited January 20, 2023 by ioa747 I know that I know nothing
Solution AspirinJunkie Posted January 20, 2023 Solution Posted January 20, 2023 (edited) Something like that?: Global $oShell = ObjCreate("Shell.Application") For $oWin In $oShell.Windows ConsoleWrite(StringFormat("\nWin-handle: %x\nLocation: %s\n", $oWin.HWND, $oWin.LocationURL)) Next Edited January 20, 2023 by AspirinJunkie
ioa747 Posted January 20, 2023 Author Posted January 20, 2023 (edited) Thanks to @AspirinJunkie Hear is the conversion to proper array for a more efficient way to enumerating all open folders Hope is OK #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include <Array.au3> Local $Test = _EnumAllOpenFolder() _ArrayDisplay($Test, "$Test") Func _EnumAllOpenFolder() Local $oShell = ObjCreate("Shell.Application") Local $sPath, $index = 0 Local $aArray[$oShell.Windows.Count + 1][2] = [["hWnd", "Path"]] For $oWin In $oShell.Windows $index += 1 $aArray[0][0] = $index $sPath = StringTrimLeft($oWin.LocationURL, 8) ; trim 'file:///' $sPath = StringReplace($sPath, "/", "\") $aArray[$index][0] = HWnd($oWin.HWND) $aArray[$index][1] = $sPath Next Return $aArray EndFunc ;==>_EnumAllOpenFolder Thanks! Edited: add HWnd ( expression ) Edited: add StringReplace($sPath, "/", "\") Edited: $oShell.Windows.Count + 1 instead ReDim after @seadoggie01 suggestion. Thanks for that Edited: changed the Exampe2 to _EnumAllOpenFolder Edited January 21, 2023 by ioa747 I know that I know nothing
seadoggie01 Posted January 20, 2023 Posted January 20, 2023 Instead of ReDim-ing your array with every iteration, you can initialize it with this: Local $aArray[$oShell.Windows.Count + 1][2] = [["hWnd", "Path"]] ioa747 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
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