Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Tooltip for help on control under mouse


  • Please log in to reply
1 reply to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
This simple example function will show a configurable helpful tooltip for control under mouse cursor.

TargetWin = Test Window

; Generated using SmartGUI Creator 3.4

Gui, Add, Button, x16 y17 w60 h30, Button
Gui, Add, Checkbox, x16 y57 w70 h30, Checkbox
Gui, Add, Edit, x116 y17 w140 h70, Edit
Gui, Show, x158 y318 h103 w269, %TargetWin%
SetTimer, Tip, 2000
Return

GuiClose:
ExitApp

Tip:
	IfWinNotActive, %TargetWin%
	{
		ToolTip
		Return
	}

	MouseGetPos,,,, ACtrl
	Tip =
	
	If ACtrl = Button1
		Tip = A Button

	If ACtrl = Button2
		Tip = A Checkbox

	If ACtrl = Edit1
		Tip = My Edit field
	
	If ACtrl <> %LastCtrl%
	{
		ToolTip, %Tip%
		LastCtrl = %ACtrl%
	}
Return

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


ghee22
  • Members
  • 36 posts
  • Last active: Nov 12 2009 04:44 PM
  • Joined: 04 Jul 2009
Thank you for the script. Is there a way to use the window handle (HWND) of each control rather than the ControlNN?

Solution:
Micahs's script is useful. Modified code below.

; requires getClassNN() from http://www.autohotkey.com/forum/viewtopic.php?t=20099&highlight=classnn+hwnd
; Note:  ControlNN(variable_name_of control) does not work.

TargetWin = Test Window

Gui, Add, Button, x16 y17 w60 h30 HWNDbutton_hwnd, Button
Gui, Add, Checkbox, x16 y57 w70 h30, Checkbox example
Gui, Add, Edit, x116 y17 w140 h70 vedit_me, Edit
Gui, Show, x158 y318 h103 w269, %TargetWin%
SetTimer, Tip, 2000
Return

GuiClose:
ExitApp

Tip:
	IfWinNotActive, %TargetWin%
	{
	  ToolTip
	  Return
	}
	
	MouseGetPos,,,, ACtrl
	Tip =
	
	If (ACtrl == getClassNN(button_hwnd)) {
		Tip = Works using control's HWND
	}
	
	If (ACtrl == getClassNN("Checkbox example")) {
		Tip = Works using control's caption
	}
	
	If (ACtrl == "Edit1") {
		Tip = Works using control's ControlNN
	}
	
	If ACtrl <> %LastCtrl%
	{
	  ToolTip, %Tip%
	  LastCtrl = %ACtrl%
	}
Return