Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Full path of files selected
#1
How get full path of files selected in any window?
Reply
#2
Here is how to get filenames of selected files in Windows Explorer:

Code:
Select All      Help
Acc a=acc("" "LIST" "+ExploreWClass" "SysListView32" "" 0x1000)
ARRAY(Acc) ar
a.Selection(ar)
int i
for i 0 ar.len
,out ar[i].Name
Reply
#3
and full path?
Reply
#4
Code:
Select All      Help
;find Explorer window
int hwnd=win("" "ExploreWClass")
;Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw) if(hwnd=b.HWND) goto g1
ret
;g1
;get shell folder view document

Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
;enumerate selected items
foreach fi sfw.SelectedItems
,out fi.Path

,
Reply
#5
Perfect, like always
Reply
#6
is there any other way to get the full path ?
in bblean i get error 0x8007000E, Für diesen Vorgang ist nicht genügend Speicher verfügbar. (not enough memory ???)
pi
Reply
#7
I don't use bblean. If class of control that displays files is not (and is not derived from) SysListView32, you probably cannot get some useful info from it.

Another method:

Code:
Select All      Help
key Cc
ARRAY(str) a
if(GetClipboardFiles(a))
,out a[0]

http://www.quickmacros.com/forum/showthread.php?tid=480
Reply
#8
syslistview is not the problem, i get the filename.
but the second script for full path is not working.
i tried also emerge desktop (another shell).
pi
Reply
#9
This works well in explorer, but not in the Open/Save dialogs of other programs.
How would I get the paths of selected files from "#32770" class dialog windows?
Reply
#10
I tried many ways when working with Open dialog in QM Icons dialog, but did not find a way that would work with all dialogs. I use CDM_GETFILEPATH message, but it works only maybe with 1% of Open dialogs.

GetClipboardFiles should work.
Reply
#11
Hi Gintaras and QMers:

I would like to merge the GetPathsOfSelectedFiles in Windows Explorer and the selected items in desktop. It would be very useful.

Please, any help?
Thanks in advance.

Macro GetPathsOfSelectedFiles
Code:
Select All      Help
;Displays full paths of selected files and folders in Windows Explorer.

;find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
;Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
,int hwnd2=b.HWND; err continue
,if(hwnd=hwnd2) goto g1
ret
;g1
;get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
;enumerate selected items
foreach fi sfw.SelectedItems
,out fi.Path
Reply
#12
I could not find a way to get paths of selected desktop icons.
Can get only names, but probably it is not useful, because then we don't know extensions (X.txt and X.doc are just X). Also cannot get paths of non-file-system items, such as Recycle Bin.
Workaround: temporarily activate desktop, send Ctrl+C, call GetClipboardFiles. But does not work if there are selected non-file-system items.
Reply
#13
Ok, I see. Well, thanks anyway.

Best regards.
Reply
#14
I do this to get the full path of the desktop icons.
Thanks Gintaras for the nice little function "FindDesktopListViewControl".
Macro FullPath Desktop Icons
Trigger F10     Help - how to add the trigger to the macro
Code:
Select All      Help
;Open the popup menu by right-click on the selected icon
if (FindDesktopListViewControl)
,rig

,;Select "Properties" from popup menu
,int w1=wait(5 WV win("" "#32768")) ;;context menu
,Acc a.Find(w1 "MENUITEM" "Properties" "" 0x1000 3)
,a.DoDefaultAction
,
,;Copy and display the full path of the icon on desktop
,int w2=win("" "#32770")
,act w2
,str fullPath.setclip  ;; clear clipboard
,key Cc              ;; copy icon full path
,fullPath.getclip      ;; copy clipboard
,if(fullPath.len)
,,out fullPath
,,'Y  ;; just close the popup window
,else
,,'Y  ;; just close the popup window
,,a.Find(FindDesktopListViewControl "LIST")
,,ARRAY(Acc) ar
,,a.Selection(ar)
,,int i
,,for i 0 ar.len
,,,_s.from("$desktop$\" ar[i].Name)
,,,out _s.expandpath
Reply
#15
The desktop window is not always Progman. Sometimes it is WorkerW.

Function FindDesktopListViewControl
Code:
Select All      Help
;/
function#

;Returns the handle of the SysListView32 control that displays desktop icons.


int w=GetShellWindow
int c=child("" "SysListView32" w 0 "id=1")
if !c
,w=win("" "WorkerW" "" 0 F"threadId={GetWindowThreadProcessId(w 0)}"); if(!w) goto gErr
,c=child("" "SysListView32" w 0 "id=1"); if(!c) goto gErr

ret c
;gErr
end "desktop window not found"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)