-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathJEE_ExplorerWinGetSelectionahk.ahk
50 lines (48 loc) · 1.38 KB
/
JEE_ExplorerWinGetSelectionahk.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
;requires:
;commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=37&t=29689
JEE_ExpWinGetSel(hWnd:=0, vSep:="")
{
local oItem, oOutput, oWin, oWindows, vCount, vOutput, vWinClass
DetectHiddenWindows("On")
(!hWnd) && hWnd := WinExist("A")
vWinClass := WinGetClass("ahk_id " hWnd)
if (vWinClass = "CabinetWClass") || (vWinClass = "ExploreWClass")
{
for oWin2 in ComObjCreate("Shell.Application").Windows
if (oWin2.HWND = hWnd)
{
oWin := oWin2
break
}
}
else if (vWinClass = "Progman") || (vWinClass = "WorkerW")
{
oWindows := ComObjCreate("Shell.Application").Windows
VarSetCapacity(hWnd, 4, 0)
;SWC_DESKTOP := 0x8 ;VT_BYREF := 0x4000 ;VT_I4 := 0x3 ;SWFO_NEEDDISPATCH := 0x1
oWin := oWindows.FindWindowSW(0, "", 8, ComObject(0x4003, &hWnd), 1)
}
else
return
vCount := oWin.Document.SelectedItems.Count
if (vSep = "")
{
oOutput := []
for oItem in oWin.Document.SelectedItems
if !(SubStr(oItem.path, 1, 3) = "::{")
oOutput.Push(oItem.path)
oWindows := oWin := oWin2 := oItem := ""
return oOutput
}
else
{
vOutput := ""
VarSetCapacity(vOutput, (260+StrLen(vSep))*vCount*2)
for oItem in oWin.Document.SelectedItems
if !(SubStr(oItem.path, 1, 3) = "::{")
vOutput .= oItem.path vSep
oWindows := oWin := oWin2 := oItem := ""
return SubStr(vOutput, 1, -StrLen(vSep))
}
}