有没有办法知道在Windows资源管理器中选择哪个文件?我一直在寻找在这里Idiots guide to ...张贴的教程,但所描述的动作是:所选文件的外壳扩展
悬停
方面
菜单属性
拖
拖放
我想知道是否有一个方法在选择文件时被调用。例如创建文件的缩略图视图。
谢谢。
有没有办法知道在Windows资源管理器中选择哪个文件?我一直在寻找在这里Idiots guide to ...张贴的教程,但所描述的动作是:所选文件的外壳扩展
悬停
方面
菜单属性
拖
拖放
我想知道是否有一个方法在选择文件时被调用。例如创建文件的缩略图视图。
谢谢。
这是我如何做,在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控制哪些选定的项目,并得到他们。现在
,这是一个黑客,也有可能是更清洁的方式...
PS:也发现了这个:Getting ListView items in C# from SysListView32 using SendMessage
需要一些巫术得到它的工作在另一个进程...
房地产代码在a French site!
我遇到了这个python脚本。
from win32com.client.gencache import EnsureDispatch
for w in EnsureDispatch("Shell.Application").Windows():
print w.LocationName + "=" + w.LocationURL
但我只得到打开的文件夹,而不是该文件夹中当前选定的项目。
任何人都有更多信息?