我有这个应用程序,它在 WindowsForms 列表框(NET 框架)中列出文件。如果在列表框中选择了多个文件,则该应用程序不支持复制操作,但同时,该应用程序支持多个文件的“拖放”事件(允许将文件“拖出应用程序”)。
我如何提取“从应用程序中拖出的”文件的路径?(例如,我将文件放在某个显示路径的程序/脚本上/将路径保存到 txt 文件中)。
答案1
由于 cmd.exe 的限制,bat 脚本最多可以处理大约 15 个文件:
@echo off
setlocal
:getfile
shift
if "%~1"=="" goto end
echo %1
goto getfile
:end
pause
绕过限制的 Autohotkey 脚本:
; The script displays the file paths. File paths that were
; dropped onto the Text control. AHK Text control. AHK Text control
; that is part of this AHK script.
; The script bypasses the ~2048 cmd.exe input parameters character limitation.
; See here for more info:
; http://support.microsoft.com/kb/830473
; http://www.tek-tips.com/viewthread.cfm?qid=1666374
;
Gui, Add, Text, vText1 h80, Drag files here
Gui, Show
return
GuiDropFiles:
MsgBox, % "A_GuiControl=" A_GuiControl "`n" ; on what AHK control were files dropped
. "A_EventInfo=" A_EventInfo "`n" ; number of files
. "A_GuiEvent =" A_GuiEvent ; all filenames, divided by `n
ExitApp
return