Here's how I do it in AutoHotkey:
GetWindowsExplorerSelectedFile(_hWnd)
{
local selectedFiles, file
; I can send ^C and parse Clipboard, but this way don't mess with clipboard at all, seems nicer.
; Warning: with this, you get only what is displayed in Explorer!
; If you kept the default Windows setting of not displaying file extensions (bad idea...),
; you will get partial file names...
ControlGet, selectedFiles, List, Selected Col1, SysListView321, ahk_id %_hWnd%
Loop, Parse, selectedFiles, `n ; Rows are delimited by linefeeds (`n).
{
If (A_Index = 1)
{
file := A_LoopField
}
Else
{
; Indicate that several files are selected, we return only the first one
; but count the total number of selected files, to indicate we return a partial result
ErrorLevel := A_Index
}
}
Return file
}
And I get the path from the Explorer edit box (which is prone to problems! May be missing or may not be configured to display the full path).
The basic idea is to ask the SysListView32 Explorer control which elements are selected and get them.
, , , , ...
PS.: : ListView # SysListView32 SendMessage
, ...
!