[COM] Help with the IDropSource and IDropTarget interfaces

Get help with using AutoHotkey and its commands and hotkeys
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

[COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 16:25

I'm not sure if this is really a Help forum topic but this is the only place for it so here goes...

I've been working on converting Sean's DragDrop script so that it works on x64. I've got it working (it works great (for the most part)) but the IDropSource and IDropTarget interfaces are created using pseudo objects and the methods are triggered using a manual approach that requires the use of the RegisterCallback command.

I would really like to get it working by creating interfaces using the built-in ComObjCreate command and if possible, controlling the events by using the ComObjConnect command but unfortunately the documentation for these interfaces are incomplete, at least for the ComObjCreate command. The interface identifier (IID) is documented but the associated COM class ID (CLSID) (if any) is nowhere to found so I can't even try to get it working.

Does anyone have any experience with these interfaces and if so, have you been able get them working using the built-in COM commands and if so, would you be willing to share your code and/or your experience?

Thanks.

Edit:
Link to Sean's version and mine (full debug mode, sorry):
https://dl.dropboxusercontent.com/u/225589492/AutoHotkey%20Forum/DragDrop/v0.0.1/DragDrop.zip
Last edited by jballi on 13 Jul 2015, 17:45, edited 1 time in total.
User avatar
BGM
Posts: 366
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 16:46

I don't have any experience here, but I am sure interested, as I have a couple of projects wherein I need to do this.

Here are a few threads that I had open (not sure if they will help any):
- How to Implement Drag and Drop
- Drop Files simulation (ahk)
- Peeking Drag-n-Drop clipboard data (ahk)
- Display and Use a File's Icon during Drag-n-Drop

Do you have a copy of Sean's Drag-n-Drop script?
User avatar
TLM
Posts: 1141
Joined: 01 Oct 2013, 07:52

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 16:50

I'm also interested in this subject as I've been trying to access certain interfaces without class names..
I originally used ole/com object viewer but you can also find most CLSID's by searching HKEY_CLASSES_ROOT\Interface
Funny enough there's one for IDropTarget {00000320-0000-0000-C000-000000000046} but not one for IDropSource, not sure why.
Hope this helps at least a bit..

btw OLE/COM Object viewer is in the Resource Kit Tools found here: https://www.microsoft.com/en-ca/downloa ... x?id=17657
Image
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:04

Thank you for your reply.
BGM wrote:Do you have a copy of Sean's Drag-n-Drop script?

Yes. My original objective was to convert that script to work on x64. I've got that working. My objective now is to get it working using the built-in AutoHotkey COM commands. That's where I need the help.
User avatar
BGM
Posts: 366
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:08

I can't download the script from the link and I'd like to look at it.
Or maybe you can share what you have come up with? (gist is a good way)
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:09

TLM wrote:I'm also interested in this subject as I've been trying to access certain interfaces without class names..
I originally used ole/com object viewer but you can also find most CLSID's by searching HKEY_CLASSES_ROOT\Interface
Funny enough there's one for IDropTarget {00000320-0000-0000-C000-000000000046} but not one for IDropSource, not sure why.
Hope this helps at least a bit..

btw OLE/COM Object viewer is in the Resource Kit Tools found here: https://www.microsoft.com/en-ca/downloa ... x?id=17657

I've looked for the appropriate classes in all of these place and in the OLE headers. But there is nothing out there (that I could find) that attaches the IDropSource and/or IDropTarget interaces to a particular CLSID. And there are thousands of them so trying them all is not very practical.
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:12

BGM wrote:I can't download the script from the link and I'd like to look at it.
Or maybe you can share what you have come up with? (gist is a good way)

I'll try to attach them both to this post. If I can't then I'll post a link to gist or similar.
User avatar
TLM
Posts: 1141
Joined: 01 Oct 2013, 07:52

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:22

jballi wrote:I've looked for the appropriate classes in all of these place and in the OLE headers. But there is nothing out there (that I could find) that attaches the IDropSource and/or IDropTarget interaces to a particular CLSID. And there are thousands of them so trying them all is not very practical.
You don't have to try them all.. OLE / COM Object Viewer lists IDropTarget's CLSID under interfaces for me... Image
going to the key I posted in regedit and searching for either one of them by name or IID will search for the specific interface.
Image
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:42

TLM wrote:
jballi wrote:I've looked for the appropriate classes in all of these place and in the OLE headers. But there is nothing out there (that I could find) that attaches the IDropSource and/or IDropTarget interaces to a particular CLSID. And there are thousands of them so trying them all is not very practical.
You don't have to try them all.. OLE / COM Object Viewer lists IDropTarget's CLSID under interfaces for me... Image
going to the key I posted in regedit and searching for either one of them by name or IID will search for the specific interface.

I tried that CLSID a while back and again when you posted this and I get an AutoHotkey runtime error - No such interface supported. I don't know if it's the wrong/inappropriate CLSID for that interface or if that interface cannot be created using that command. I don't have enough COM experience to know which or to know what to try next.
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:48

I'm sorry, the only version of mine that I could pull together on short notice was full of debug code/documentation and included other functions for the test that I wrote. I included the whole thing in a zip project for your review. I've added the link to the first post.
User avatar
BGM
Posts: 366
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:57

jballi - thanks for the link. I'll take a look at this too.
User avatar
TLM
Posts: 1141
Joined: 01 Oct 2013, 07:52

Re: [COM] Help with the IDropSource and IDropTarget interfaces

13 Jul 2015, 17:58

I pretty much have the same issue as you but with a different interface
Have you tried the old COM_L library with this? The reason I ask is because I got as far as DllCall("ole32\CoInitialize",... and then DllCall("ole32\**the interface**",
but then realized this is what COM_L lib does already
.. going to give it a try a little later and will report back if I get it working..
would be nice if this was easier tbh.
Image
just me
Posts: 4685
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

14 Jul 2015, 03:15

Great stuff so far. I'm curious whether it can be simplified.

jballi wrote: Possible AutoHotkey bugs:

* When the IDropTarget function is used with standard parameters,
Ex: IDropTarget(A,B=0,C=0,D=False,E=Whatever), it works fine on a 32-bit
version of AutoHotkey. However, on the 64-bit version of AutoHotkey,
values for many of the later variables on the list (for the example: C,
D, etc.) are invalid for some of the methods. The only way to get this
to work is to use variadic parameters and extract the parameter
values by address. Since the AutoHotkey documentation does not explain
how to do this for parameters other than the first, the exact address
offsets were discovered by trial and error. For the 32-bit version of
AutoHotkey, offsets were always 4 bytes apart. This makes sense since
most 32-bit data types are 4 bytes. For the 64-bit version of
AutoHotkey however, the offsets were sometimes 8-bytes apart but
sometimes 4 bytes. The previous parmeter's data type appears to be the
guide for what the offsets for each parameter would be. This might
somewhat explain why regular parameters don't work on the 64-bit version
of AutoHotkey. Not sure if this is an AutoHotkey bug or if this what
developers can expect to deal with writing callback functions for the
64-bit version of AutoHotkey.

I'd call it a 32-bit issue rather than a bug. Your observations are most likely related to the POINTL parameter. The size of this parameter is 8 bytes, but the size of parameters used with DllCall() or callback functions is limited to 4 bytes for AHK32. So the POINTL parameter has to be passed as two parameters. On AHK64 it fits the parameter size of 8 bytes and only one parameter is passed.
Remaining with AHK 1.1.25.02 until v2 will become beta.
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

14 Jul 2015, 18:35

I was hoping to find someone who had some experience creating these interfaces using built-in AutoHotkey commands but either 1) no one has done it successfully yet or 2) these interfaces cannot be created using the ComObjCreate command which I assume runs the "ole32\CoCreateInstance" function. The run-time error that you get when trying to create the IDropTarget interface is 0x80004002 (E_NOINTERFACE). The Microsoft description of this error is "The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface." As I stated earlier, I don't know if it's the wrong/inappropriate CLSID for these interfaces or if the IDropSource and/or IDropTarget interfaces can be created using the ComObjCreate command.

If anyone has any additional information or anything else to try, please post it!
just me
Posts: 4685
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

16 Aug 2015, 02:54

I've spent some time on this stuff because I wanted to use drag-and-drop. I couldn't manage to create AHK COM objects, too. But I restructured the interface wrappers to make them easier to use and added a few new features to IDropTarget.

You can find the whole result on GitHub. I add only the IDropTarget related scripts here for the forum search:

Code: [Select all] [Expand] [Download] (IDropTarget.ahk)GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] (IDataObject.ahk)GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] (IEnumFORMATETC.ahk)GeSHi © Codebox Plus

Remaining with AHK 1.1.25.02 until v2 will become beta.
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

16 Aug 2015, 16:44

I've only spent a few minutes looking at it but so far, it looks pretty cool. You're doing a few things that I had never seen before. For example, keeping the original source drag icon definitely adds to the user experience.

Good work! You should publish this in the main script forum. A few "real life" examples wouldn't hurt. Thanks for sharing.
just me
Posts: 4685
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

17 Aug 2015, 01:33

I found a few articles about the IDragSourceHelper and IDropTargetHelper interfaces:
It was somewhat easy to get the target helper working, but I had no luck with the source helper as yet.

The IDropTarget part seems to work stable now. But I still want to get the IDragSourceHelper working, too.

This is what I tried so far:

Code: [Select all] [Expand] [Download] (DoDragDrop.ahk)GeSHi © Codebox Plus


Code: [Select all] [Expand] [Download] (IDragSourceHelper.ahk)GeSHi © Codebox Plus


InitializeFromWindow is sometimes working somehow. But InitializeFromBitmap always retrieves the meaningful error E_FAIL. Due to my very limited knowledge about COM I don't have any idea, what else I could try. Maybe someone more experienced could jump in and help.
Remaining with AHK 1.1.25.02 until v2 will become beta.
just me
Posts: 4685
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

23 Aug 2015, 02:30

Nobody can contribute?
Remaining with AHK 1.1.25.02 until v2 will become beta.
jballi
Posts: 431
Joined: 29 Sep 2013, 17:34

Re: [COM] Help with the IDropSource and IDropTarget interfaces

24 Aug 2015, 00:59

just me wrote:Nobody can contribute?

To be fair, coding for COM is tough. Also, hosting this in the "Ask For Help" forum will probably not provide the right kind of traffic for this topic. Not sure where to move it though.
just me
Posts: 4685
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

24 Aug 2015, 02:37

jballi wrote:To be fair, coding for COM is tough.

Couldn't have said it better myself! It's like treading on very thin ice for me. ;)
Remaining with AHK 1.1.25.02 until v2 will become beta.

Return to “Ask For Help”

Who is online

Users browsing this forum: Elaphe666, Phroster, Yahoo [Bot] and 50 guests