Shell extension for the selected file

Is there a way to find out which file is selected in Windows browser? I watched the tutorial posted here is a guide for idiots ... but the steps described are:

soaring

context

Menu Properties

resistance

drag and drop

I wonder if there is a method that is called when a file is selected. For example, to create a thumbnail of a file.

Thank.

+3
source share
2 answers

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
, ...

!

0

python script.

from win32com.client.gencache import EnsureDispatch 

for w in EnsureDispatch("Shell.Application").Windows(): 
    print w.LocationName + "=" + w.LocationURL 

, .

- ?

0

Source: https://habr.com/ru/post/1698662/


All Articles