Skip to content

Instantly share code, notes, and snippets.

@tmplinshi
Created April 21, 2014 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmplinshi/11130182 to your computer and use it in GitHub Desktop.
Save tmplinshi/11130182 to your computer and use it in GitHub Desktop.
; v1.0.0
; http://www.autohotkey.com/board/topic/105112-enum-explorer-receive-all-explorer-in-z-order/
Enum_Explorer(hWnd=0, lParam=0) {
If hWnd
{
WinGetClass, class, ahk_id %hwnd%
If class in CabinetWClass,ExploreWClass
{
array := object(lParam)
If IsObject(array[hwnd])
{
array.ZOrder.insert(array[hwnd])
}
}
return 1
}
Array := {}
array.ZOrder := {}
for Item in ComObjCreate("Shell.Application").Windows
If (Path := PathCreateFromURL(Item.LocationURL)) ; URL = NULL while explorer is Library...
{
Array[Item.HWND, "path"] := path
Array[Item.HWND, "URL"] := Item.LocationURL
Array[Item.HWND, "Prog"] := Item.Name
Array[Item.HWND, "processpath"] := Item.FullName
Array[Item.HWND, "hwnd"] := Item.HWND
}
Static callback := RegisterCallBack("Enum_Explorer", "", 2) ; EnumWindowsProc
DllCall("EnumWindows", "Ptr", callback, "uint", Object(Array))
return Array
}
PathCreateFromURL( URL )
{
VarSetCapacity( fPath, Sz := 2084, 0 )
DllCall( "shlwapi\PathCreateFromUrl" ( A_IsUnicode ? "W" : "A" )
, "Str",URL, "Str",fPath, "UIntP",Sz, "UInt",0 )
return fPath
}
; Example:
; Array := Enum_Explorer()
; If array.ZOrder.maxindex()
; {
; For i, o in Array.ZOrder
; {
; tt .= "path: " o.path "`n"
; tt .= "URL: " o.URL "`n"
; tt .= "Prog: " o.Prog "`n"
; tt .= "processpath: " o.processpath "`n"
; tt .= "hwnd: " o.hwnd "`n-------------------------`n"
; }
; }
; msgbox,% tt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment