Sign in to follow this  
Followers 0
Suppir

How to catch files that drag & dropped on trey menu?

8 posts in this topic

Hello!

User drags & drops some files (or directories) to traymenu of the autoit script.

How to get full pathnames of dropped objects?

Share this post


Link to post
Share on other sites



That's not a trivial problem.

The tray icon is just a button in a ToolbarWindow32 control. The control belongs to the desktop, not your AutoIt process, so I don't know that you can register the WM_DROPFILES message you would have to catch. If you look at TraySetOnEvent() in the help file you don't see a $TRAY_EVENT_DROPFILES as one of the supported special IDs.

:graduated:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes, I understand.

But I think there is a way exists. Something like:

If IsPressed("01") And MouseOverTray() Then
     GetObjectsPathFromDropFiles()  # maybe there is a special dllcall exists to get this data??
Endif
Edited by Suppir

Share this post


Link to post
Share on other sites

The tray icon is just a button in a ToolbarWindow32 control. The control belongs to the desktop, not your AutoIt process, so I don't know that you can register the WM_DROPFILES message you would have to catch. If you look at TraySetOnEvent() in the help file you don't see a $TRAY_EVENT_DROPFILES as one of the supported special IDs.

If that's the case, how you track right click menus? Posted Image

Share this post


Link to post
Share on other sites

If that's the case, how you track right click menus? Posted Image

I think the desktop process that owns the control passes notifications to the window associated with the button. The point being that only messages the desktop process is designed to pass will get passed, and DROPFILES (plus the struct that would tell you what was dropped) does not appear to be one of them.

I am certainly not an API expert though, and smarter people can/will correct me if I'm wrong.

:graduated:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I think the desktop process that owns the control passes notifications to the window associated with the button. The point being that only messages the desktop process is designed to pass will get passed, and DROPFILES (plus the struct that would tell you what was dropped) does not appear to be one of them.

I'm not disagreeing with you, there is no default behaviour for tray dropping.

I have yet to see an application support it or even say it's possible. Whatever the OP is after is going to cause confusion and be rarely used if distributed to others, bar himself.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hello,

I've played around with this before and this is as far as i got.

Pops messagebox when the mouse is released on the icon or something is "dropped" onto the icon. Although when you drag files over the icon you get the no entry simple or denied which ever way you look at it.

#include <Constants.au3>
#NoTrayIcon

Opt("TrayMenuMode",1)
Opt("TrayOnEventMode", 1)
TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "MyFunc") ; register custom func
TraySetState()

While 1
    Sleep(10) ; useless loop
WEnd

Func MyFunc()

    MsgBox(32, "Title", "Replace messagebox with some awesome way to get what was in mouse?")
EndFunc

I'm sure you can register some external DLL to find what files have been selected by the mouse?

Steve

EDIT:

I dont know if this could be of any help, i havent looked just something i found in a text file with the above script

http://msdn.microsoft.com/en-us/library/ms742859.aspx#Drag_and_Drop_Events

Edited by Steveiwonder

They call me MrRegExpMan

Share this post


Link to post
Share on other sites

There are work-arounds to see when the mouse is released on the icon, but nothing I've found goes on to get the file path(s) being dropped.

The page you linked to is for .NET DragDrop.Drop Attached Event, which is not much help to AutoIt, and the SysTray toolbar is not a .NET created object anyway.

:graduated:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0