(Context) Menu With Timed Tooltips

1 post in this topic

Sunaj 1

This is an updated version of eltorro's brillant script for providing tooltips in menus - it now works with context menus as well (which frankly took me an ridiculous amount of time to figure out, be sure to right click the app and test it out!). See original posting for debugging version and more. Enjoy

CODE

;Menu With Timed Tooltips

;Stephen Podhajecki [eltorro] gehossafats@netmdc.com

;

;Converted to GUIOnEventMode (0.2) by [sunaj]

;Changes/updates:

;

;a) Removes need for Sleep() = smoother GUI

; Removes debugging engine, use original by eltorro for debugging

;c) Changes msg pull interval to be faster, no CPU usage difference

; noticed.

;d) Works with context menus now - hack had to be implemented because

; context menus do NOT allow for registering when mouse is moved away in

; the same way as normal menus. Works in uniform way for both type of

; menus now.

;e) 0.2 fixes problem where tooltip would be wrongly shown if user moved

; mouse quickly over a context menu, tweak EventLoop() as needed.

#include <GuiConstants.au3>

#include <Array.au3>

Opt("GUIOnEventMode", 1)

Global $USE_TOOLTIP = True

Local $aCtrlArray[1], $aCtrlMsgArray[1], $ControlID

Global $defaultstatus = "Ready"

Global $status

Global $MenuItemId

Global $IDLECounter = 0 ; When 5 is reached tooltip is closed

Global $EVENT

Global $TIMERENABLED = False ; Flag set when SetTimer api is called

Global $TIP_TIMER ; Timestamp holder for tooltip visiblilty

Global Const $TIP_TIMER_ID = 999 ; Timer id for SetTimer api

Global Const $TIPSHOW = 1 ; Event

Global Const $TIPVISIBLE = 2 ; Event

Global Const $TIP_TTL = 2333 ; how long to show tooltip

Global Const $TIP_DELAY = 333 ; how long to wait to show tooltip

Global Const $MSG_INTERVAL = 33 ; Interval Windows will use to send

;Window Message Hooks.

Global Const $WM_MENUSELECT = 0x011F

Global Const $WM_TIMER = 0x0113

Global Const $WM_ENTERIDLE = 0x0121

;GUIRegisterMsg ($WM_ENTERMENULOOP, "MenuTipHandler")

GUIRegisterMsg ($WM_MENUSELECT, "MenuTipHandler")

GUIRegisterMsg ($WM_ENTERIDLE ,"MenuTipHandler") ; to make context menues disappear when moving pointer off menu without closing it