/* TheGood How to detect doubleclicks in ListBox */ Gui, Add, ListBox, hwndhLB, This is a listbox item OnMessage(515, "OnDblClick") ;Intercept WM_LBUTTONDBLCLK notifications Gui, Show Return GuiClose: ExitApp OnDblClick(wParam, lParam, msg, hwnd) { ;Make the var global so that we can access it Global hLB ;Make sure the notification comes from the listbox If (hwnd = hLB) { ;Get item count. 395 = LB_GETCOUNT SendMessage 395, 0, 0,, ahk_id %hwnd% iCount := ErrorLevel ;Check for error If (ErrorLevel = 0xFFFFFFFF) Return ;Get the bottom edge of the last item. 408 = LB_GETITEMRECT VarSetCapacity(uRect, 16, 0) SendMessage 408, iCount - 1, &uRect,, ahk_id %hLB% ;% iBottomEdge := (ErrorLevel <> 0xFFFFFFFF) ? NumGet(uRect, 12) : 0 ;Extract the Y coordinate of the mouse click from lParam (high word) iY := (lParam - Mod(lParam, 0x10000)) / 0x10000 ;Check if mouse click is under or over bottom edge If (iY > iBottomEdge) GoSub ListBoxDoubleClickOffItem ;The dblclick was off an item Else GoSub ListBoxDoubleClickOnItem ;The dblclick was on an item } } ListBoxDoubleClickOnItem: MsgBox You double-clicked on an item! Return ListBoxDoubleClickOffItem: MsgBox You double-clicked off an item! Return