AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tooltip for help on control under mouse

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Mon Mar 21, 2005 1:04 pm    Post subject: Tooltip for help on control under mouse Reply with quote

This simple example function will show a configurable helpful tooltip for control under mouse cursor.

Code:

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

_________________
Back to top
View user's profile Send private message
ghee22



Joined: 04 Jul 2009
Posts: 36

PostPosted: Sat Nov 07, 2009 2:22 pm    Post subject: Reply with quote

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.

Code:

; 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

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group