I want to fake a drag and drop action (dragging a file from lets say Windows-Explorer to a certain program). This program has a window with four drop-targets.
The target-program has its own graphical subsystem, so its neither based on WinForms nor WPF. I tried WinSpy and all it detects is the window itself, but none of the controls.
When I drag above one of the targets it shows a Windows’ copy option though (like when you drag a file to a folder on another drive).
I don’t believe there’s any documented way.
You could send
WM_DROPFILES, but this (1) requires you to put the filename into an undocumented HDROP structure in the target process memory ahead of time, and (2) is the older method for accepting files, it won’t work if the application uses the newerIDropTargetAPIs.IDropTargetis actually designed to be more general than just dragging files from explorer: there’s a Win32 API,DoDragDrop, which allows an application to act as a drag source so the user can drop its data into other applications. UnfortunatelyDoDragDropwatches mouse movement directly, so you’d need to simulate mouse movement and button release in order to control where the item dropped. Even this won’t work unless the other window is on top of the z-order, sinceDoDragDropfinds the window under the cursor, and will interfere with any mouse activity the user is doing. So it should be used as a last resort.