문제

Windows 탐색기에서 어떤 파일을 선택하고 있는지 알 수있는 방법이 있습니까? 여기에 게시 된 튜토리얼을보고 있습니다 바보 가이드에 대한 ... 그러나 설명 된 조치는 다음과 같습니다.

호버

문맥

메뉴 속성

견인

끌어서 놓기

파일을 선택할 때 호출되는 메소드가 있는지 궁금합니다. 예를 들어 파일의 썸네일보기를 작성합니다.

감사.

도움이 되었습니까?

해결책

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
}

그리고 나는 탐색기의 편집 필드에서 경로를 얻습니다 (문제가 발생하기 쉬운 경우! 결석 할 수 있거나 전체 경로를 표시하지 않도록 설정할 수 있음).

핵심 아이디어는 SyslistView32 Explorer의 제어에 선택한 항목이 무엇인지 묻고 가져 오는 것입니다.

자, 그것은 해킹입니다. 아마도 더 깨끗한 방법이 있습니다 ...

추신 : 또한 이것을 찾았습니다. sendmessage를 사용하여 syslistview32에서 c#에서 ListView 항목 가져 오기
다른 과정에서 작업하기 위해 부두가 필요합니다 ...

실제 코드 프랑스 사이트!

다른 팁

나는이 파이썬 스크립트를 발견했다.

from win32com.client.gencache import EnsureDispatch 

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

그러나 해당 폴더에서 현재 선택된 항목이 아닌 폴더 만 엽니 다.

누구나 더 많은 정보가 있습니까?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top