Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have this application that lists files in a WindowsForms listbox (NET framework). The application does not support the copy operation if multiple files are selected in the listbox, but at the same time, the application supports 'drag and drop' event for multiple files (allows dragging the files 'out of the application').

How can I extract the paths of the files 'dragged out of the application'? (i.e. I drop the files on some program / script that shows me the paths / saves the paths to a txt file).

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The bat script will work with up to about 15 files, because of the limitation of the cmd.exe:

@echo off 
setlocal
:getfile
shift
if "%~1"=="" goto end
echo %1
goto getfile
:end

pause

Autohotkey script that bypasses the limitation:

; 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
share|improve this answer
    
There is no windows limitation for 15 files. Would it make sense there there is something else going on with the program? Also, what is the error? –  soandos Jun 13 '12 at 0:42
    
"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item." The error shows up even if I drag the files onto an empty .bat script. –  colemik Jun 13 '12 at 8:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.