 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Fri Aug 08, 2008 3:09 pm Post subject: [function] sTooltip - colored standard tooltip with timeout |
|
|
hi
here's a lil function to show a tooltip for a given time with a custom color in rgb format (fore and background is supported). this function shows how to obtain the hWnd of the tooltip
a lil word on usage:
| Code: | | sTooltip(sTooltipTxt,seconds=5,bg=0xFFFFE7,fg=0x0,x=-1,y=-1) |
aboves line is from function declaration it can be read as this:
sTooltipTxt is a variable or a String containing the text to show
seconds is the time in seconds to show the tip the =5 shows its default value of 5 seconds
bg is the backgroundcolor - the 0x (needed) is to show its a hexadecimal number of 6 digits length (3 pairs). each pair represents a part of color. eg 1st two the redcolor, 2nd the green color, 3rd the blue part. it works much the same as colors in html - its default is ffffe7 which is the yellowish standard color.
fg is the foregroundcolor. the declaration is the same as with background
0x0 is the same as 0x000000 and means black as default value.
x and y are coordinates. unless u need to u can dismiss these safely to follow the tooltip the mouse for the time being displayed.
| Code: | ; example call
sTooltip("Tooltip with custom Colors",5,0xffff00,0x00ff00)
sTooltip(sTooltipTxt,seconds=5,bg=0xFFFFE7,fg=0x0,x=-1,y=-1) {
; (w) derRaphael / zLib Style released / v 0.3
if (Seconds+0=0)
Seconds = 5
StartTime := EndTime := A_Now
EnvAdd,EndTime,Seconds,Seconds
fg := ((fg&255)<<16)+(((fg>>8)&255)<<8)+(fg>>16) ; rgb -> bgr
bg := ((bg&255)<<16)+(((bg>>8)&255)<<8)+(bg>>16) ; rgb -> bgr
tooltip,% (ttID:="TooltipColor " A_TickCount)
tThWnd1:=WinExist(ttID ahk_class tooltips_class32)
; remove border
; WinSet,Style,-0x800000,ahk_id %tThWnd1%
SendMessage, 0x413, bg,0,, ahk_id %tThWnd1% ; 0x413 is TTM_SETTIPBKCOLOR
SendMessage, 0x414, fg,0,, ahk_id %tThWnd1% ; 0x414 is TTM_SETTIPTEXTCOLOR
; according to http://msdn.microsoft.com/en-us/library/bb760411(VS.85).aspx
; there is no limitation on vista for this.
Loop,
{
if (EndTime=A_Now)
Break
else
if (x<0) || (y<0)
ToolTip, %sTooltipTxt%
else
ToolTip, %sTooltipTxt%, %x%, %y%
sleep, 50
}
ToolTip
} |
if no time is given, it defaults to 5 seconds
IMPORTANT: it is seconds - not miliseconds. Tooltips wont be colored in VISTA.
greets
dR _________________
Last edited by DerRaphael on Tue Aug 12, 2008 7:59 pm; edited 2 times in total |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Fri Aug 08, 2008 4:18 pm Post subject: |
|
|
| In my Vista it does not take the colors, but the tooltip flickers. Did you test it in XP? |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Fri Aug 08, 2008 4:21 pm Post subject: |
|
|
i tested on win2k - have no vista here _________________
|
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Fri Aug 08, 2008 10:00 pm Post subject: |
|
|
Wunderbar! Unglaublich nützlich
bestätigt am XP SP3 _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
greatful guest Guest
|
Posted: Sat Aug 09, 2008 11:15 am Post subject: |
|
|
I like the idea of colored tooltips. But I also have the flickering (Win98).
So here is my butchered version of your code that seems to work well on win98 and XP. | Code: | sTooltip("Tooltip with custom Backgroundcolor",5,0xff8000)
sTooltip(sTooltipTxt,seconds=5,bg=0xFFFFE7,fg=0x0,x=-1,y=-1) {
; (w) derRaphael / zLib Style released
if (Seconds+0=0)
Seconds = 5
StartTime := EndTime := A_Now
EnvAdd,EndTime,Seconds,Seconds
fg := ((fg&255)<<16)+(((fg>>8)&255)<<8)+(fg>>16) ; rgb -> bgr
bg := ((bg&255)<<16)+(((bg>>8)&255)<<8)+(bg>>16) ; rgb -> bgr
tooltip,% (ttID:="TooltipColor " A_TickCount)
tThWnd1:=WinExist(ttID ahk_class tooltips_class32)
; remove border
; WinSet,Style,-0x800000,ahk_id %tThWnd1%
SendMessage, 0x400+19, bg,fg,, ahk_id %tThWnd1%
ToolTip, %sTooltipTxt%
MouseGetPos, lastx, lasty
Loop,
if (EndTime=A_Now)
Break
else {
MouseGetPos, x, y
if (lastx != x) || (lasty != y) {
ToolTip, %sTooltipTxt%
lastx := x, lasty := y
}
sleep, 50
}
ToolTip
}
|
|
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 230 Location: GERMANY
|
Posted: Sat Aug 09, 2008 11:25 am Post subject: |
|
|
| Thanks for sharing this. Very useful. |
|
| Back to top |
|
 |
shajul
Joined: 15 Sep 2006 Posts: 33 Location: India
|
Posted: Sun Aug 10, 2008 7:59 am Post subject: Feedback |
|
|
Just feedback,
it does not work in vista (Home premium) |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sun Aug 10, 2008 9:31 am Post subject: |
|
|
minor update
greets
dR |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Tue Aug 12, 2008 8:10 pm Post subject: |
|
|
updated usage with a few explanations
greets
dR _________________
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|