Code:
Gui, +LastFound
Gui, Margin, 50, 50
Gui, Add, Button, hwndbtn1, Button1
Gui, Add, Button, hwndbtn2 x+50, Button2
Gui, Show,, Test
GuiHWND := WinExist()
Delay = 850
VarSetCapacity( HoverTime, 16, 0 )
NumPut( 16, HoverTime, 0, "UINT" )
NumPut( Delay, HoverTime, 12, "UINT" )
OnMessage(0x2A1, "WM_MOUSEHOVER")
OnMessage(0x200, "WM_MOUSEMOVE")
return
GuiClose:
Exitapp
WM_MOUSEHOVER(wparam, lparam, msg, hwnd)
{
Global
If ( A_GuiControl )
Tooltip, You are hovering the mouse over %A_GuiControl%
Else If ( previoushwnd = GuiHWND )
Tooltip, You are hovering the mouse over the gui's client-area
TooltipTime := A_TickCount + Delay
}
WM_MOUSEMOVE(wparam, lparam, msg, hwnd)
{
Global HoverTime, previoushwnd, TooltipTime
If ( A_TickCount > TooltipTime )
{
Tooltip,
TooltipTime := 0x7FFFFFFFFFFFFFFF
Reset = 1
}
If ( hwnd = previoushwnd ) && !Reset
return
NumPut( 0x80000000, HoverTime, 4, "UINT" )
DllCall("TrackMouseEvent", UInt, &HoverTime )
NumPut( 1, HoverTime, 4, "UINT" )
NumPut( previoushwnd := hwnd, HoverTime, 8, "UINT" )
DllCall("TrackMouseEvent", UInt, &HoverTime )
}
I'm not sure I can explain it adequately, but this is how to get a tooltip when hovering over something in a GUI.