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
}
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