Here a version using
ToolTip() - Advanced ToolTip features
All functions are included here (using Standard version)
Code:
CoordMode,Mouse,Screen
ToolTipOptions:="B0000FF F00FF00 t200 I1 M1"
;*************gui1*********************
Gui, Add, Button,,Click to do nothing
Gui, Add, DropDownList,vDDL,red|blue|green||
Gui, Add, Checkbox,, Click to enable
Gui, Add, Edit, HwndMYEdit,This is an edit box
Gui, Add, Button,, Ok
Gui, Add, Button, x+ yp, Cancel
Gui, Add, Button, x+ yp, Retry
Gui, Show,x200
;set tooltips for each button - supply text, variable, classnn, or hwnd
setTip("Button1", "This button does absolutely nothing.") ;using the classnn
setTip("Ok", "Begin the Process") ;using the caption
setTip("Cancel", "Cancel Whatever is Happening!")
setTip("Retry", "Do Over")
setTip("Click to enable", "Checkbox")
setTip(DDL, "Dropdownlist") ;using the variable
setTip(MYEdit, "The infamous edit control") ;using the hwnd
;*************gui2*********************
Gui, 2:Add, Button,,Click to do nothing
Gui, 2:Add, DropDownList,vDDL2,red|blue|green||
Gui, 2:Add, Checkbox,, Click to enable
Gui, 2:Add, Edit, HwndMYEdit2,This is edit box two
Gui, 2:Add, Button,, Ok
Gui, 2:Add, Button, x+ yp, Cancel
Gui, 2:Add, Button, x+ yp, Retry
Gui, 2:Show,x400
;set tooltips for each button - supply text, variable, classnn, or hwnd
setTip("Button1", "This button does absolutely nothing. gui2", 2) ;using the classnn
setTip("Ok", "Begin the Process gui2", 2) ;using the caption
setTip("Cancel", "Cancel Whatever is Happening! gui2", 2)
setTip("Retry", "Do Over gui2", 2)
setTip("Click to enable", "Checkbox gui2", 2)
setTip(DDL2, "Dropdownlist part two: This time it's personal", 2) ;using the variable
setTip(MYEdit2, "The infamous edit control redeux", 2) ;using the hwnd
;TipsState(0) ;disable tooltips
Return
2guiClose:
guiClose:
ExitApp
Return
/*
tooltipV2.ahk
Version: 1.2
By: Micahs
CallWith: (You can use Hwnd, var, text, classnn)
setTip("Button1", "This button does absolutely nothing.") ;using the classnn
setTip("Ok", "Begin the Process") ;using the caption
setTip("Cancel", "Cancel Whatever is Happening!")
setTip(DDL, "Dropdownlist") ;using the variable
setTip(MYEdit, "The infamous edit control") ;using the hwnd
*/
setTip(tipControl, tipText, guiNum=1) ;tipControl - text,variable,hwnd,classnn ; tipText - text to display ; gui number, default is 1
{
global
local List_ClassNN
Gui,%guiNum%:Submit,NoHide
Gui,%guiNum%:+LastFound
WinGet, tipGui_guiID, ID
WinGet, List_ClassNN, ControlList
StringReplace, List_ClassNN, List_ClassNN, `n, `,, All
IfInString, tipControl, %List_ClassNN% ;it is a classnn
{ tipGui_ClassNN := tipControl ;use it as is
}
Else ;must be text/var or ID
{ tipGui_ClassNN := tipGui_getClassNN(tipControl, guiNum) ;get the classnn
}
tipGui_%guiNum%_%tipGui_ClassNN% := tipText ;set the tip
If(!tipGui_Init) ;enable tooltips when the first one is set, but only if TipsState has not been called (either to enable or disable)
{ TipsState(1)
}
}
TipsState(ShowToolTips)
{
global tipGui_Init
tipGui_Init = 1 ;iniialize this latch
If(ShowToolTips)
{ OnMessage(0x200, "WM_MOUSEMOVE") ;enable tips
}
Else
{ OnMessage(0x200, "") ;disable tips
}
}
WM_MOUSEMOVE()
{
global
Critical
IfEqual, A_Gui,, Return
MouseGetPos,,,tipGui_outW,tipGui_outC
If(tipGui_outC != tipGui_OLDoutC)
{ tipGui_OLDoutC := tipGui_outC
Gui, %A_Gui%:+LastFound
ToolTip(1,"")
tipGui_ID := WinExist()
SetTimer, tipGui_killTip, 1000
counter := A_TickCount + 500
Loop
{ MouseGetPos,,,, tipGui_newC
IfNotEqual, tipGui_outC, %tipGui_newC%, Return
looper := A_TickCount
IfGreater, looper, %counter%, Break
sleep,50
}
MouseGetPos,x,y
ToolTip(1,tipGui_%A_Gui%_%tipGui_outC%,tipGui_outC,ToolTipOptions)
}
SetTimer, tipGui_killTip, 1000
Return
tipGui_killTip:
MouseGetPos,,, tipGui_outWm
If(tipGui_outWm != tipGui_ID) or (A_TimeIdle >= 4000)
{ SetTimer, tipGui_killTip, Off
ToolTip(1,"")
}
Return
}
tipGui_getClassNN(tipControl, g=1) ;tipControl = text/var,Hwnd ;g = gui number, default=1
{
Gui,%g%:+LastFound
guiID := WinExist() ;get the id for the gui
WinGet, List_controls, ControlList
StringReplace, List_controls, List_controls, `n, `,, All
;if id supplied do nothing special
IfNotInString, tipControl, %List_controls% ;must be the text/var - get the ID
{ mm := A_TitleMatchMode
SetTitleMatchMode, 3 ;exact match only
ControlGet, o, hWnd,, %tipControl% ;get the id
SetTitleMatchMode, %mm% ;restore previous setting
If(o) ;found match
{ tipControl := o ;set sought-after id
}
}
Loop, Parse, List_controls, CSV
{ ControlGet, o, hWnd,, %A_LoopField% ;get the id of current classnn
If(o = tipControl) ;if it is the one we want
{ Return A_Loopfield ;return the classnn
}
}
}
/*
ToolTip() by HotKeyIt http://www.autohotkey.com/forum/viewtopic.php?t=40165
Options can include any of following parameters separated by space
In - Icon 1-3, e.g. I1
Xn Yn - screen coordinates, can be empty to display near the mouse or caret to display near caret
e.g. X200 Y300 or Xcaret Ycaret
bn - background color, e.g. BFFFFFF or B0xFFFFFF
fn - text color, e.g. F000000 or F0x000000
dn - delay in seconds, e.g. d5
tn - Transparency, e.g. t200
o1 - activate ballontip, e.g. O1
c1 - display close button, e.g. C1
m1 - activate click trough effect, e.g. M1
*/
ToolTip(_tool_tip_id_="", text=" ", title="", options=""){ ;i x y b f d t o c m
static _tt_hwnd_list_
global #_ti_
If !#_ti_
VarSetCapacity(#_ti_, 40, 0),#_ti_:=Chr(40),NumPut(0x20,#_ti_,4)
If !_tool_tip_id_
{
Loop,Parse,_tt_hwnd_list_,|
If WinExist("ahk_id " RegExReplace(A_LoopField,"\d+\."))
DllCall("DestroyWindow","Uint",hwnd1)
_tt_hwnd_list_=
Return
}
If options
Loop,Parse,options,%A_Space%
{
option:= SubStr(A_LoopField,1,1)
If option
%option%:= SubStr(A_LoopField,2)
}
If RegExMatch(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.([^\|]+)",hwnd)
hwnd := hwnd1
If (!WinExist("ahk_id " hwnd1) and text!="")
{
_tt_hwnd_list_:=RegExReplace(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.[^\|]+\|")
hWnd := DllCall("CreateWindowEx", "Uint", 0x8, "str", "tooltips_class32", "str", "", "Uint", (C ? 80 : 0)+(O ? 115 : 50), "int", 0, "int", 0, "int", 0, "int", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0) ;param4 0xc3 0x80
_tt_hwnd_list_.= "|" . _tool_tip_id_ . "." . hWnd . "|"
NumPut(&_tool_tip_id_,#_ti_,36)
DllCall("SendMessage", "Uint", hWnd, "Uint", 1028, "Uint", 0, "Uint", &#_ti_) ; TTM_ADDTOOL
DllCall("SendMessage", "Uint", hWnd, "Uint", 1041, "Uint", 1, "Uint", &#_ti_) ; TTM_TRACKACTIVATE
WinHide,ahk_id %hWnd%
If !C
WinSet, Disable,,ahk_id %hwnd%
If M
WinSet,ExStyle,^0x20,ahk_id %hwnd%
}
If ((B!="" ? SetToolTipColor(hwnd,B) :) or (F !="" ? SetToolTipTextColor(hwnd,F) :) and text="")
DllCall("DestroyWindow","Uint",hwnd), _tt_hwnd_list_:=RegExReplace(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.[^\|]+\|")
else if !D
ShowToolTip(hwnd,x,y,text,title,I,T)
else
{
A_Timer := A_TickCount, D *= 1000
Loop
If (A_TickCount - A_Timer > D or ShowToolTip(hwnd,x,y,text,title,I,T))
Break
DllCall("DestroyWindow","Uint",hwnd), _tt_hwnd_list_:=RegExReplace(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.[^\|]+\|")
}
Return hwnd
}
SetToolTipTitle(hwnd,title,I="0"){
title := (StrLen(title) < 96) ? title : ("…" . SubStr(title, -97))
; TTM_SETTITLE ; 0: None, 1:Info, 2: Warning, 3: Error. n > 3: assumed to be an hIcon.
DllCall("SendMessage", "Uint", hWnd, "Uint", 1056, "Uint", I, "Uint", &Title)
}
SetToolTipColor(hwnd,B){
B := (StrLen(B) < 8 ? "0x" : "") . B
B := ((B&255)<<16)+(((B>>8)&255)<<8)+(B>>16) ; rgb -> bgr
DllCall("SendMessage", "Uint", hWnd, "Uint", 1043, "Uint", B, "Uint", 0) ; TTM_SETTIPBKCOLOR
}
SetToolTipTextColor(hwnd,F){
F := (StrLen(F) < 8 ? "0x" : "") . F
F := ((F&255)<<16)+(((F>>8)&255)<<8)+(F>>16) ; rgb -> bgr
DllCall("SendMessage", "Uint", hWnd, "Uint", 1044, "Uint",F & 0xFFFFFF, "Uint", 0) ; TTM_SETTIPTEXTCOLOR
}
ShowToolTip(hwnd,x,y,text,title="",I="0",T=""){
local xc,yc,xw,ywd
MouseGetPos, xc,yc
WinGetPos,xw,yw,,,A
xc+=15,yc+=15
If (x="caret")
xc:=xw+A_CaretX
If (y="caret")
yc:=yw+A_CaretY
DllCall("SendMessage", "Uint", hWnd, "Uint", 1042, "Uint", 0, "Uint", ((x="" ? xc : (x="caret" ? xc : x)) & 0xFFFF)|((y="" ? yc : (y="caret" ? yc : y)) & 0xFFFF)<<16) ; TTM_TRACKPOSITION
If (title!="")
SetToolTipTitle(hwnd,title,I)
NumPut(&text,#_ti_,36)
DllCall("SendMessage", "Uint", hWnd, "Uint", 1048, "Uint", 0, "Uint", A_ScreenWidth) ;TTM_SETMAXTIPWIDTH
DllCall("SendMessage", "Uint", hWnd, "Uint", 0x40c, "Uint", 0, "Uint", &#_ti_) ; TTM_UPDATETIPTEXT
If T
WinSet,Transparent,%t%,ahk_id %hwnd%
}