AutoHotkey Community

It is currently May 26th, 2012, 6:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: March 21st, 2005, 2:04 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
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

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 3:22 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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



Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, siterip, Stigg and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group