Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global Search (+ get selected files in folder)
#8
Function GetFolderWindowItems
Code:
Copy      Help
;/
function! ARRAY(str)&a [hwnd] [flags] ;;flags: 1 selection

;Gets full paths of items in the folder that is opened in Windows Explorer (WE).
;Returns 1 on success, 0 if failed. If empty, or empty selection (flag 1), returns 1, but the array is empty.

;a - receives paths.
;hwnd - WE window handle. If 0 or omitted, finds WE window that is above all other WE windows in Z order.


a=0
SHDocVw.InternetExplorer ie=GetFolderWindowIE(hwnd); if(!ie) ret
IShellView isv
IShellBrowser isb
IServiceProvider isp=+ie
isp.QueryService(uuidof(IShellBrowser) uuidof(IShellBrowser) &isb)
isb.QueryActiveShellView(&isv)
IDataObject ido
isv.GetItemObject(iif(flags&1 SVGIO_SELECTION SVGIO_ALLVIEW) IID_IDataObject &ido); err ret 1
FORMATETC f.cfFormat=RegisterClipboardFormat(CFSTR_SHELLIDLIST)
f.dwAspect=DVASPECT_CONTENT; f.lindex=-1; f.tymed=TYMED_HGLOBAL
STGMEDIUM sm
if(ido.GetData(&f &sm)) ret
CIDA* c=GlobalLock(sm.hGlobal)

int i
a.create(c.cidl)
for i 0 c.cidl
,ITEMIDLIST* il=ILCombine(+(c+c.aoffset[0]) +(c+c.aoffset[i+1]))
,PidlToStr(il &a[i])
,CoTaskMemFree il

GlobalUnlock(sm.hGlobal); ReleaseStgMedium(&sm)

err+ ret
ret 1

Function GetFolderWindowIE
Code:
Copy      Help
;/
function'SHDocVw.InternetExplorer [hwnd]

;Gets SHDocVw.InternetExplorer of folder that is opened in Windows Explorer (WE).

;hwnd - WE window handle. If 0 or omitted, finds WE window that is above all other WE windows in Z order.


SHDocVw.ShellWindows sw._create
SHDocVw.InternetExplorer ie
type __GFWIE hwnd SHDocVw.InternetExplorer'ie
ARRAY(__GFWIE) a
int hwnd2
str ss
foreach ie sw
,ss=ie.LocationURL; err continue
,;out ss
,if(!ss.begi("file:///")) continue ;;web browser or non-file-system folder
,ss.get(ss 8)
,ss.findreplace("/" "\")
,ss.escape(8)
,;out ss
,hwnd2=ie.HWND; err continue
,if(!hwnd2) continue
,if(hwnd)
,,if(hwnd2=hwnd) ret ie
,else
,,__GFWIE& r=a[]
,,r.hwnd=hwnd2; r.ie=ie

if(hwnd) ret

hwnd=GetWindow(_hwndqm GW_HWNDFIRST)
rep
,if(!hwnd) break
,int i
,for(i 0 a.len) if(a[i].hwnd=hwnd) ie=a[i].ie; ret ie
,hwnd=GetWindow(hwnd GW_HWNDNEXT)


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)