Is there a relatively easy to understand script that will take a filepath/filename and an app/window title and drop the file onto the specified window? This would be for Windows 7.
It's not a big deal to perform the manual drag/drop, but it's something I have to do 1x/week so if it's not difficult to automate, that would be nice to do.
I found this: https://autohotkey.com/board/topic/4146 ... ntry638376
but it's a bit over my head.
Simulate drag and drop file onto app?
Re: Simulate drag and drop file onto app?
Here is an example that drops a list of files on the PSPad editor where they open in tabs ( win10 pro and ahk unicode 1.1.26.01 )
Code: Select all
SetTitleMatchMode, 2
list_files:={} ;define array name
data=
(
c:\Users\momoko\AppData\Roaming\ahk\run avi\avitoday.ahk
c:\Users\momoko\AppData\Roaming\ahk\run avi\clipverify.ahk
c:\Users\momoko\AppData\Roaming\ahk\run avi\copy selected avi.ahk
c:\Users\momoko\AppData\Roaming\ahk\run avi\ddd.ahk
c:\Users\momoko\AppData\Roaming\ahk\run avi\del files.ahk
)
loop,parse,data,`n,`r
list_files[A_Index]:=A_LoopField
DropFiles("PSPad", list_files)
DropFiles(window, files)
{
for k,v in files
memRequired+=StrLen(v)+1
hGlobal := DllCall("GlobalAlloc", "uint", 0x42, "ptr", memRequired+21)
dropfiles := DllCall("GlobalLock", "ptr", hGlobal)
NumPut(offset := 20, dropfiles+0, 0, "uint")
for k,v in files
StrPut(v, dropfiles+offset, "utf-8"), offset+=StrLen(v)+1
DllCall("GlobalUnlock", "ptr", hGlobal)
PostMessage, 0x233, hGlobal, 0,, %window%
if ErrorLevel
DllCall("GlobalFree", "ptr", hGlobal)
}
Re: Simulate drag and drop file onto app?
Firstly I appreciate to you for sharing it.noname wrote: ↑22 Oct 2017, 07:28Here is an example that drops a list of files on the PSPad editor where they open in tabs ( win10 pro and ahk unicode 1.1.26.01 )
Code: Select all
SetTitleMatchMode, 2 list_files:={} ;define array name data= ( c:\Users\momoko\AppData\Roaming\ahk\run avi\avitoday.ahk c:\Users\momoko\AppData\Roaming\ahk\run avi\clipverify.ahk c:\Users\momoko\AppData\Roaming\ahk\run avi\copy selected avi.ahk c:\Users\momoko\AppData\Roaming\ahk\run avi\ddd.ahk c:\Users\momoko\AppData\Roaming\ahk\run avi\del files.ahk ) loop,parse,data,`n,`r list_files[A_Index]:=A_LoopField DropFiles("PSPad", list_files) DropFiles(window, files) { for k,v in files memRequired+=StrLen(v)+1 hGlobal := DllCall("GlobalAlloc", "uint", 0x42, "ptr", memRequired+21) dropfiles := DllCall("GlobalLock", "ptr", hGlobal) NumPut(offset := 20, dropfiles+0, 0, "uint") for k,v in files StrPut(v, dropfiles+offset, "utf-8"), offset+=StrLen(v)+1 DllCall("GlobalUnlock", "ptr", hGlobal) PostMessage, 0x233, hGlobal, 0,, %window% if ErrorLevel DllCall("GlobalFree", "ptr", hGlobal) }
I have simple A.txt file on my desktop. Lets say I want to that A file drop onto "ahk_class Notepad" and when I try it It works perfect!
However, I have a ahk_class X, window and whenever i try to drop onto that "X" window it's not work for me. Any Idea about it?
I think the problem is with X windows because when I manually drag & drop onto that X window ( Just title area ) it's not work ofc when I put it manually onto that window ARENA (not title arena) it's work.
When I drag & drop manually onto Notepad (title ARENA) it's work.
So I think It's about Notepad title arena accepting to drop , but X window is not accept.
So is there any change to fix it for my X window? It maybe about 0x42 or 0x233 stuffs but I have really no idea because I cannot understand those codes. Thank you for helping us.
Who is online
Users browsing this forum: Chunjee, inseption86, jaka1 and 345 guests