Drop files into an application Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
panhartstuff
Posts: 25
Joined: 21 Jan 2018, 07:40

Drop files into an application  Topic is solved

08 Nov 2018, 17:40

I'm trying to use a code by RHCP from this old forums. It's meant to simulate dropping files into an application
https://autohotkey.com/board/topic/4146 ... ntry638376

Code: Select all

DropFiles( FileList, wTitle="", Ctrl="", X=0, Y=0, NCA=0 ) 
{
 characterSize := A_IsUnicode ? 2 : 1
 StringReplace, FileList, FileList, `r`n, `n , All
 VarSetCapacity( DROPFILES,20,32 ),  DROPFILES.=FileList "`n`n",  nSize:=StrLen(DROPFILES)*characterSize
 StringReplace, DROPFILES,DROPFILES, `n,`n, UseErrorLevel
 Loop %ErrorLevel%
	NumPut( 0, DROPFILES, InStr(DROPFILES,"`n",0,0)*characterSize - characterSize, A_IsUnicode ? "Short" : "Char" )

 pDP := &DROPFILES
 NumPut(20, pDP+0)
 NumPut(X, pDP+4)
 NumPut(Y, pDP+8)
 NumPut(NCA, pDP+12)
 NumPut(A_IsUnicode ? 1 : 0, pDP+16)
 hDrop := DllCall( "GlobalAlloc", UInt,0x42, UInt, nSize )
 pData := DllCall( "GlobalLock", UInt, hDrop)
 DllCall( "RtlMoveMemory", UInt,pData, UInt,pDP, UInt, nSize )
 DllCall( "GlobalUnlock", UInt,hDrop )
 PostMessage, 0x233, hDrop, 0, %Ctrl%, %wTitle% ; WM_DROPFILES := 0x233
}
But I'm getting a bizzare error message when trying to drop image files into MSPaint.
Image
This is the code I'm using:
DropFiles( "C:\Users\MyName\Pictures\ClipboardDump\dump.png", "ahk_class MSPaintApp")

I've also tried to use the previous versions of the code from that thread, but I'm getting a similar error message. Weirdly, the gibberish at the end of the error message also varies.

What am I doing wrong here?

EDIT:
Never mind, I got it to work by using RPHC's HDrop function instead

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 296 guests