i tried bringing up this issue over at the autohotkey forum, but maybe i could get some suggestions here as well.
i cannot seem to be able to come up with a solution to perform the following:
--simulate a drag and drop operation (probably using COM), however
--instead of doing it all at once, let the user manually focus the window & coordinates where the drop should be performed, then, following a hotkey, perform the drop to whichever window appears active at the time, at whichever mouse coordinates the cursor is at. basically a drag&drop using keyboard shortcuts as opposed to a mouse click & drag.
after following some suggested past solutions, i was able to simulate a file-drop operation into some applications. for some (they happen to be utilizing a lot of child windows), my implementation is not working.*
here is what i am using at the moment:
Code: Select all
#a::
MouseGetPos, MouseCoordX, MouseCoordY, WindowUnderMouse, , ,
WindowToDropTo := "ahk_id "WindowUnderMouse
PostMessage, 0x233, HDrop(SubPat1, MouseCoordX, MouseCoordY), 0, , %WindowToDropTo%
;NOTE:
;SubPat1 contains the file path & filename
Code: Select all
HDrop(fnames,x,y) {
fns:=RegExReplace(fnames,"\n$")
fns:=RegExReplace(fns,"^\n")
hDrop:=DllCall("GlobalAlloc","UInt",0x42,"UInt",20+StrLen(fns)+2)
p:=DllCall("GlobalLock","UInt",hDrop)
NumPut(20, p+0) ;offset
NumPut(x, p+4) ;pt.x
NumPut(y, p+8) ;pt.y
NumPut(0, p+12) ;fNC
NumPut(0, p+16) ;fWide
p2:=p+20
Loop,Parse,fns,`n,`r
{
DllCall("RtlMoveMemory","UInt",p2,"Str",A_LoopField,"UInt",StrLen(A_LoopField))
p2+=StrLen(A_LoopField)+1
}
DllCall("GlobalUnlock","UInt",hDrop)
Return hDrop
}
thank you!
*i furthermore realised that some applications perform more advanced tasks when the user is about to drop a file: for instance, hovering on top of a control for x amount of seconds within an application whilst dragging a file, the application may further adjust how it will deal with the file once the LMB is released and the drop is performed. i wonder if there is a way to simulate this; basically this introduces one more layer to the operation, not just the dropping itself, but the state before the drop to which certain applications may react in a specific way...