-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathEnum_Explorer.ahk
55 lines (52 loc) · 1.44 KB
/
Enum_Explorer.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
; 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 = "CabinetWClass")
{
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