Jump to content


Photo

Drag&Drop Files


  • Please log in to reply
9 replies to this topic

#1 majkinetor

majkinetor
  • Fellows
  • 4511 posts

Posted 09 January 2007 - 03:25 PM

Is it possible to have some feature to be able to drag & drop arbitrary files to some window ?

Example:

Current folder contains number of images in different format.
I want to drop all jpg images to the batch processing 3th party window.

So, I would like to have something like this:

Run, BatchProcesor.exe

loop, *.jpg
 files .= A_LoopFileLongName . "`n"

Drop, files, ahk_class BatchProcessor

I don't see that this can be done now without nasty workarounds.
Searching around I found this related topic:
<!-- m -->http://www.autohotke... ... 1246#91246<!-- m -->

Almost all applications now handle drag & drop, many times this to be the only available method of communication with outside world. I think all users of AHK would benefit of such command. Furthermore, I think that all workarounds that can be get by using MouseClickDrag will not be so flowless and succesiful then this eventual alternative.

Thx.

#2 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 09 January 2007 - 04:19 PM

Looks like we need Com (Ole) to do this: How to Implement Drag and Drop Between Your Program and Explorer

#3 majkinetor !

majkinetor !
  • Guests

Posted 09 January 2007 - 08:31 PM

I will try to investigate also and see if I can manage to create something.
What do you think about it ?

#4 Chris

Chris
  • Administrators
  • 10727 posts

Posted 09 January 2007 - 09:41 PM

It sounds interesting. If you find out more beyond the link that was posted above, please let me know.

#5 Kahz

Kahz
  • Members
  • 190 posts

Posted 11 January 2007 - 02:40 AM

Could this be done with a plugin or dll call, perhaps?

#6 panofish

panofish
  • Members
  • 176 posts

Posted 07 October 2011 - 04:51 AM

I've seen all related posts on this topic and this one is the closest to what I want. Unfortunately, it looks like nobody has published a working solution.

Specifically, I would like to see an ahk program with a listview of filenames, which the user can drag and drop from the listview to the desktop or explorer window, such that the ahk program can detect the drop location/path.

It looks like Sean may know how to implement some com objects to achieve this, but I haven't seen any working examples. :(

#7 fragman

fragman
  • Members
  • 1591 posts

Posted 07 October 2011 - 03:27 PM

It would also be nice to see how to implement control-specific file acception for AHK GUIs. COM might be a way to go indeed.

#8 SKAN

SKAN
  • Administrators
  • 9063 posts

Posted 07 October 2011 - 07:34 PM

Unfortunately, it looks like nobody has published a working solution.
...
It looks like Sean may know how to implement some com objects to achieve this, but I haven't seen any working examples. :(


er.. have you seen this: <!-- m -->http://www.autohotke... ... 217#273217<!-- m -->

#9 infogulch

infogulch
  • Moderators
  • 717 posts

Posted 07 October 2011 - 08:15 PM

So, in ahk_L...

Dir := "C:\SomeDir"
Name := "filename"

; i'm assuming this copies a file to the clipboard, i wonder how to copy more than one?
ComObjCreate("Shell.Application").NameSpace(dir).ParseName(name).InvokeVerb("copy")

if DllCall("ole32\OleGetClipboard", "Uint*", pdata) == 0
    DllCall("shell32\SHDoDragDrop", "Uint", 0, "Uint", pdata, "Uint", 0, "Uint", 1|4, "UintP", nEffect)

; how to release pdata object?


#10 HjP

HjP
  • Members
  • 53 posts

Posted 16 February 2012 - 09:36 PM

Hi,

I use AHK_L Version1.1.02.03.

The code provided by infogulch (previous post) consists of two steps:
1. copying a certain file to the clipboard
2. dropping that file

I was able to accomplish step 1:
sPath := A_ScriptFullPath
SplitPath, sPath, sName, sDir
ComObjCreate("Shell.Application").NameSpace(sDir).ParseName(sName).InvokeVerb("copy")
Sleep 10000
For any strange reasons, the file (in the code above, the script file) is only in the clipboard as long as the script is running. That's why I added Sleep 10000 at the end.

I was not able to accomplish step 2. Regarding the code provided by infogulch in the previous post, I wonder how the target window (the window in which the file is to be dropped) is specified.

Could someone please provide a working example, which drops some file (e.g., the script file) into the windows explorer.

Thanks,
HjP