Jump to content


Photo

SystemTray Drag and Drop [Ahk_L]


  • Please log in to reply
No replies to this topic

#1 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 02 July 2012 - 07:36 PM

I searched around a bit and could not find any script for this, there is this topic, but it is long gone from this land.

This is just a simple way of running scripts through Drag n' Drop on the TrayIcon

Still have some issues:

1 - I don't know if there is another way of finding the tray icon position, so I used ImageSearch and a timer to keep looking for the icon and change the GUI's position.

2 - For some unknown reason I could not get WM_MOUSEHOVER to work so it could show a TrayTip.

AhkPath = F:\Autohotkey\Autohotkey.exe

ImageSearch, IconX, IconY, 500, 0, A_ScreenWidth, A_ScreenHeight, Imagens/AhkIcon.png

ControlGetPos, CPosX, CPosY, , , ToolBarWindow321, ahk_class Shell_TrayWnd

ClickPosX := IconX - CPosX
ClickPosY := CPosY/2

Gui, Color, FFFFFF
Gui, +AlwaysOnTop +ToolWindow -Caption +LastFound +HwndHFakeGui
Gui, Add, Picture, x0 y0, Imagens/AhkIcon.png
Gui, Show, x%IconX% y%IconY% w14 h14, FakeGui, NoActivate
OnMessage(0x204, "WM_RBUTTONDOWN")
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x2A1, "WM_MOUSEHOVER")
SetTimer, SetToTop, 500
return

WM_RBUTTONDOWN()
{	
	ControlClick,  ToolBarWindow321, ahk_class Shell_TrayWnd, , right, , x%ClickPosX% y%ClickPosY%
}

WM_LBUTTONDOWN()
{
	ControlClick, ToolBarWindow321, ahk_class Shell_TrayWnd, , Left, , x%ClickPosX% y%ClickPosY%
}

WM_MOUSEHOVER()
{
	TrayTip, Drag n' Drop, Drag and drop .ahk files on icon to run them, 5
}

GuiDropFiles:
Run  %AhkPath% "%A_GuiEvent%"
return

SetToTop:
ImageSearch, IconX, IconY, 500, 0, A_ScreenWidth, A_ScreenHeight, Imagens/AhkIcon.png
WinMove, FakeGui, , %IconX%, %IconY%
WinSet, AlwaysOnTop, On, FakeGui
return