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 

Using Tooltip for Permanent Help for any Control on any GUI

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



Joined: 20 Jan 2007
Posts: 73
Location: Melbourne

PostPosted: Sat Aug 25, 2007 1:39 pm    Post subject: Using Tooltip for Permanent Help for any Control on any GUI Reply with quote

I hate writing help files, in fact detest it, so i went looking for a way to use tooltip to do it as i wrote my apps, i got a few ideas from here and there and put the following Demo together which i now use in Every Application that uses a Gui. It has some error checking for Illegal chars eg : . \ etc and can detect any Control that has text (except a static). It is also GUI sensitive and you can have the same named buttons on any Gui displaying different Tooltips, you will see this in the demo.
The best thing is not having any more help files to write, and tooltip is flexible enough to be NOT in anybodys way when using the programs.

If anybody with more experience can go over my code and shorten and tighten it a little more, i would appreciate it.

Code:
; Language:       English
; Platform:       Win9x/NT
; Author:         T. Gowshall <trubbleguy@optusnet.com.au>
; MouseOver and display Tooltip Demo
#NoEnv
#SingleInstance,Force

Gosub buttoninfo ;get the tooltip info for the mouseover

;this is sample Gui replace with your Gui
Gui, Add, Button, x16 y7 w90 h40 gshowgui2, Show Gui 2`nMore examples
Gui, Add, Edit,x16 y57 w90 L1 ,text
Gui, Add, Button, x126 y7 w90 h40 , Button2
Gui, Add, CheckBox, x126 y48 w90 h40 , funny box
Gui, Add, Button, x236 y7 w90 h40 , Button3
Gui, Add, Button, x346 y7 w90 h40 , Button4
Gui, Add, Button, x456 y7 w90 h40 gGuiClose , exit
Gui, Add, Button, x456 y57 w90 h20 ,small exit
Gui, 2:Add, Button, x16 y7 w90 h40 gclosegui2, Close Gui 2
Gui, 2:Add, Edit,x16 y57 w90 L1 ,text
Gui, 2:Add, Button, x126 y7 w90 h40 , Button2`nThree lines`nand still tooltips
Gui, 2:Add, CheckBox, x126 y48 w90 h40 , funny box
Gui, 2:Add, Button, x236 y7 w90 h40 , Click for`n    C:\-.
Gui, 2:Add, Button, x346 y7 w90 h40 , Button4
Gui, 2:Add, Button, x456 y7 w90 h40 gGuiClose , exit
Gui, 2:Add, Button, x456 y57 w90 h20 ,Small Exit
Gui, Show, x131 y91 h90 w575, First GUI Window

;the next line is a must and must be placed before Return in the main loop.
;usually after GUI SHOW
OnMessage(0x200,"MOUSEOVER")
Return
;###############################################
buttoninfo:
;define the tooltips for the Control here, the number 1 is for Gui 1:
;If the Control has spaces in the name eg. word1 word2,
;make the variable word1word2 without spaces
;all spaces in the Controls name are removed for the variable,
TT_1_ShowGui2MoreExamples=this button turns on`nthe other Gui 
TT_2_CloseGui2=this button will close`nthis second Gui 
TT_1_text=ooh look its text`nIt will only Display like this while it displays 'text'`nChange the word text in the box and see what happens`n after you move the mouse away and then back to this control
TT_1_funnybox=ooh look its funny box on GUI 1
TT_1_Button2=this is button two`nIt used to popup "BUTTON 2"
TT_2_Button2Threelinesandstilltooltips =three lines of text, and Tooltips work
TT_1_Button3=this is button three`nOR Button 3
TT_2_clickforC=this button has`nlots of bad stuff like`n: \ - and . in it
TT_1_Button4=this is button four `nOn Gui 1
TT_2_Button4=this is button four `nOn Gui 2
TT_1_exit=exit by clicking here`nOr you can just`nKeep Playing`nThis is Gui 1 `nAnother message line `nAnother message line `nAnother message line `nAnother message line `nAnother message line `nAnother message line
TT_2_exit=exit by clicking here`nThis button works the same as the one on Gui 1`nBut we are over Gui 2
TT_2_SmallExit=This Control has spaces in the name but it works`nSmallExit is how its assigned to the Variable`nNot Small Exit`nand its displaying on Gui 2
Return
;###############################################
;The bit that does all the work
MOUSEOVER()
{
If A_Gui<=0 ;check if mouse is not on any gui
{
   Tooltip ;clear before return
   Return
}
   {
   MouseGetPos, X,Y,,, ;get the mouse co-ordinates
   X:=X+20 ;move it over a bit
   _tword=%A_GuiControl% ;make A_GuiControl a modifyable variable
   StringReplace,_tword,_tword,%A_Space%,,all ;remove the spaces so it can find the tooltip
   StringReplace,_tword,_tword,-,,all ;remove -
   StringReplace,_tword,_tword,:,,all ;remove :
   StringReplace,_tword,_tword,\,,all ;remove \
   StringReplace,_tword,_tword,.,,all ;remove .
   StringReplace,_tword,_tword,`n,,all ;remove any line returns
   _tip:=TT_%A_Gui%_%_tword% ;get the tooltip to display
   Tooltip,%_tip%,%X%,%Y% ;display it
   }
}   
Return
;###############################################
;Stuff below here is just code #################
showgui2:
Gui, 2:Show, x131 y220 h90 w575, Second GUI Window
Return
;###############################################
closegui2:
Gui, 2:cancel
Return

GuiClose:
ExitApp
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
corrupt



Joined: 29 Dec 2004
Posts: 2384

PostPosted: Sun Aug 26, 2007 1:23 am    Post subject: Reply with quote

Cool Smile . Here's another topic you may find interesting if you haven't read it already.
Back to top
View user's profile Send private message Visit poster's website
Trubbleguy



Joined: 20 Jan 2007
Posts: 73
Location: Melbourne

PostPosted: Sun Aug 26, 2007 2:30 am    Post subject: I think im close but have added depth to it Reply with quote

I read what you linked to and hope the additions end up in the Gui Add eventually..
I expanded on the similar code using 'Multiple GUI' tips and using control names using no spaces in the name variables for the actual tip.
Using one line of code per tooltip is the most economical i can get as some of those other ways of coding use up to 3 lines per tooltip, per control.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Firewolf91



Joined: 19 Oct 2007
Posts: 127
Location: PA

PostPosted: Wed Dec 19, 2007 6:43 pm    Post subject: Reply with quote

thanks for posting this!
i was looking around to first see if there was a way to implement javascript/CSS with AHK for the hovering tooltips because i wanted to customize them and change how they looked (transparencies, shapes, etc).
gave up on that because my javascript is rusty, not too advanced, and it didn't look like it would work.
then i looked thru the help files and examples for AHK's version...and tailor it to my needs. was playing with it till i came across your script, which worked just fine for what i needed!

if i add to it or improve anything on it, i'll repost what i did.
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