Send "Drag & Drop File(s)" MessageI was looking for this functionality before, and couldn't figure out the correct method for using the WM_DROPFILES message. Thankfully today I came across the thread 'Drag and Drop - the other way around', and found working, but flawed, code for doing exactly this. Specifically, post #60 by Martin (his 'DoDragDrop' function).
I cleaned up the code, added error checking, Unicode & x64 support, and fixed the Global memory management issues. The result is down below.
Also, see ProgAndy's COM implementation of Drag&Drop: 'Drag and Drop with Explorer'.
Another good reference, besides those in the thread above, is this article at CodeProject: 'How to Implement Drag and Drop Between Your Program and Explorer'
Examples of usage:
$hNPPlus=WinGetHandle("[CLASS:Notepad++]") $aNPPPos=WinGetPos($hNPPlus) ;~ WinActivate($hNotePad) $sProgramFiles=@ProgramFilesDir If @AutoItX64 Then $sProgramFiles&=' (x86)' $iRet=_FileDragDrop($hNPPlus,@ScriptFullPath&'|'&$sProgramFiles&"\AutoIt3\Include\Memory.au3",$aNPPPos/2,$aNPPPos/2) ConsoleWrite("Return: "&$iRet&" @error="&@error&", @extended="&@extended&@CRLF)
Be sure to credit the original authors, or leave the headers intact, if you use the code
*edit: for some friggin reason I can't post the code in the post - I get a 'You must enter a post' error message - wtf. Attaching it for now..
2010-12-4 (yup, today!):
- Fixed ANSI implementation
- Changed Memory allocation type to 'Fixed' (thanks trancexx)
- Added X, Y position parameters - actually needed for some programs (Notepad++ for example)
Edited by Ascend4nt, 14 September 2011 - 02:41 AM.