2

I'm trying to write a script that drops the current playing file from Winamp into Tabbles (a file tagging software http://tabbles.net ) I found this example but it didn't help much: http://www.autohotkey.com/board/topic/41467-make-ahk-drop-files-into-other-applications/

How do you generate a file drop event (like 'drag and drop' without dragging though) in a program, if you have the file path? Thank you.

Mike Rotchy
  • 21
  • 1
  • 2
  • Please post your code and describe where it failed. Also, what AHK version are you using? – MCL Jun 15 '13 at 23:14
  • I bet you don't have to mimic user input. Probably, it would suffice to run the .exe with your file as a start parameter. Have you checked the docs for ways to automate your process? – MCL Jun 15 '13 at 23:29
  • Just thinking out loud. You could use WinGetTitle and extract the filename from the windows title, and use that to feed it into the 2nd application. Try AHK Windows Spy to see if the Windows title provides enough data to extract the currently playing file. – Robert Ilbrink Jun 16 '13 at 12:03

1 Answers1

2

If you wish to emulate a drag and drop action without actually performing a MouseClickDrag you can use the following code:

; Drop test.txt into an *existing* notepad window
; Modify the class to match Tabbles window class
PostMessage, 0x233, HDrop("C:\test.txt"), 0,, ahk_class Notepad

HDrop(fnames,x=0,y=0) { 
   fns:=RegExReplace(fnames,"\n$") 
   fns:=RegExReplace(fns,"^\n") 
   hDrop:=DllCall("GlobalAlloc","UInt",0x42,"UPtr",20+StrLen(fns)+2) 
   p:=DllCall("GlobalLock","UPtr",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","UPtr",p2,"AStr",A_LoopField,"UPtr",StrLen(A_LoopField)) 
      p2+=StrLen(A_LoopField)+1 
   } 
   DllCall("GlobalUnlock","UPtr",hDrop) 
   Return hDrop 
}

Tested in AHK_L. Let me know if this helped!

Elliot DeNolf
  • 2,920
  • 1
  • 15
  • 12
  • Thank you Elliot, it works! The problem was that I was using Windows 8. Once I've tried it in Win7 everything went smooth. For some reason it doesn't work in Win8. – Mike Rotchy Jun 19 '13 at 08:35
  • Now if I could only find a more elegant solution of copying the file path from Winamp. Right now I have to click and select a file in the playlist and then run the script that does: Ctr+E (opens the edit playlist entry window), Ctr+C (copy file path), Esc (closes the window). With AHK WindowSpy I found that Winamp displays only the ID3 tag info of the file playing, not the path. – Mike Rotchy Jun 19 '13 at 08:55
  • 1
    @MCL The Tabbles software doesn't accept parameters, I've tried that first. I'm using AHK_L, will post the script when finished, thank you – Mike Rotchy Jun 19 '13 at 09:06