ToolTipFont / ToolTipColor - options for the ToolTip command

Post your working scripts, libraries and tools for AHK v1.1 and older
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by burque505 » 18 Aug 2018, 18:06

@Flipeador, thanks again. I always appreciate your posts and your tireless providing of help to forum members.
Regards,
burque505

User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by joedf » 20 Aug 2018, 08:20

drozdman wrote:@joedf
It doesn't have to be fast. I just select some text and press the hotkey, then another text and so on (a few seconds between).
Sometimes it happens with the first hotkey.

So other people don't experience this? I tried to run it without other scripts running, but it still happens.
Are you running any clipboard software? CL3, Greenshot, Ditto, Hardcopy, ClipJump, etc?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

drozdman
Posts: 78
Joined: 05 Dec 2015, 01:07

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by drozdman » 20 Aug 2018, 15:21

@joedf
No. No other scripts running, neither.
The lines with a clipboard assignment create the problem: clipboard = %last_clipboard%` %clipboard%. Even changing it to clipboard:=clipboard gives an error.
Though, it's not that important, so we can give it a break.

User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by joedf » 21 Aug 2018, 08:04

weird... okay. Some kind of OpenClipboard issue...
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

robodesign
Posts: 932
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by robodesign » 18 Feb 2019, 13:04

rommmcek wrote:
02 Dec 2017, 11:21
After almost one year using ToolTipFont for ToolTipAll now I switched to Fnt library! It shouldn't affect other processes and is more reliable.
Can one change tooltip colors [text and background] with Fnt Library? I saw how one can change the font, but... it is not clear how to change its colors.

Thank you .

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by rommmcek » 27 Jun 2019, 09:07

Sorry, didn't see your post!
At the time I made ToolTipFnt() didn't know how to do it. Today I looked into just me's ToolTipEx() and it was fairly easy. See here!

jadams
Posts: 73
Joined: 13 Mar 2020, 10:48

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by jadams » 09 Jun 2020, 10:05

Is anybody aware of a way to alter the drop shadow on a tooltip? I would love it if it could look like the default shadows on windows 10 Microsoft Explorer.

Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by Gregorian » 23 Sep 2020, 05:59

My script doesn't work anymore when I use this.
This script turns off all my AHK scripts when I press tab, and when I press tab again, it turns all my AHK scripts back on again.
It's also supposed to show "WRITE MODE" while all my AHK scripts are turned off.

It works fine with a normal tooltip, but when I include stuff like ToolTipColor or ToolTipFont it stops working.

Doesn't work:

Code: Select all

#IfWinActive ahk_exe Resolve.exe
{
Write_mode:=1
Tab::
if (Write_mode=0)
	{
	ToolTip
	Write_mode:=1
	}
else
	{
	ToolTipFont("s20", "Comic Sans MS")
	ToolTipColor("Black", "White")
	ToolTip, WRITE MODE, 0, 0
	Write_mode:=0
	}
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\quick zoom.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\B = Back to last stop and play.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\TimeLineClick-master\TimelineClick.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete start to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete end to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change transition length.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Create Cross Dissolve Transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Smooth Cut transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Dip to Color Dissolve Transition.ahk ahk_class AutoHotkey
Return
}

User avatar
boiler
Posts: 16706
Joined: 21 Dec 2014, 02:44

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by boiler » 23 Sep 2020, 08:15

Did it stop working because it gives you an error saying “Call to nonexistent function”? How did you include the functions in your script?

Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by Gregorian » 23 Sep 2020, 18:53

boiler wrote:
23 Sep 2020, 08:15
Did it stop working because it gives you an error saying “Call to nonexistent function”?
No. What happens is:
The message "WRITE MODE" appears when I press tab, and it disappears when I press tab again. That message is working just fine.
What doesn't work is the deactivation of all my AHK scripts.
boiler wrote:
23 Sep 2020, 08:15
How did you include the functions in your script?
Like this (this is the whole script):

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


CoordMode, ToolTip, Screen

; ToolTipOpt v1.004
; Changes:
;  v1.001 - Pass "Default" to restore a setting to default
;  v1.002 - ANSI compatibility
;  v1.003 - Added workarounds for ToolTip's parameter being overwritten
;           by code within the message hook.
;  v1.004 - Fixed text colour.
 
ToolTipFont(Options := "", Name := "", hwnd := "") {
    static hfont := 0
    if (hwnd = "")
        hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
    else
        DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
 
ToolTipColor(Background := "", Text := "", hwnd := "") {
    static bc := "", tc := ""
    if (hwnd = "") {
        if (Background != "")
            bc := Background="Default" ? "" : _TTG("Color", Background)
        if (Text != "")
            tc := Text="Default" ? "" : _TTG("Color", Text)
        _TTHook()
    }
    else {
        VarSetCapacity(empty, 2, 0)
        DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
            , "ptr", (bc != "" && tc != "") ? &empty : 0)
        if (bc != "")
            DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
        if (tc != "")
            DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
    }
}
 
_TTHook() {
    static hook := 0
    if !hook
        hook := DllCall("SetWindowsHookExW", "int", 4
            , "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
            , "uint", DllCall("GetCurrentThreadId"), "ptr")
}
 
_TTWndProc(nCode, _wp, _lp) {
;    Critical 999
   ;lParam  := NumGet(_lp+0*A_PtrSize)
   ;wParam  := NumGet(_lp+1*A_PtrSize)
    uMsg    := NumGet(_lp+2*A_PtrSize, "uint")
    hwnd    := NumGet(_lp+3*A_PtrSize)
    if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
        _hack_ = ahk_id %hwnd%
        WinGetClass wclass, %_hack_%
        if (wclass = "tooltips_class32") {
            ToolTipColor(,, hwnd)
            ToolTipFont(,, hwnd)
        }
    }
    return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
 
_TTG(Cmd, Arg1, Arg2 := "") {
    static htext := 0, hgui := 0
    if !htext {
        Gui _TTG: Add, Text, +hwndhtext
        Gui _TTG: +hwndhgui +0x40000000
    }
    Gui _TTG: %Cmd%, %Arg1%, %Arg2%
    if (Cmd = "Font") {
        GuiControl _TTG: Font, %htext%
        SendMessage 0x31, 0, 0,, ahk_id %htext%
        return ErrorLevel
    }
    if (Cmd = "Color") {
        hdc := DllCall("GetDC", "ptr", htext, "ptr")
        SendMessage 0x138, hdc, htext,, ahk_id %hgui%
        clr := DllCall("GetBkColor", "ptr", hdc, "uint")
        DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
        return clr
    }
}

#IfWinActive ahk_exe Resolve.exe
{
Write_mode:=1
Tab::
if (Write_mode=0)
	{
	ToolTip
	Write_mode:=1
	}
else
	{
	ToolTipFont("s20", "Comic Sans MS") ; [b]<-- If I delete these two lines, it works just fine,[/b] 
	ToolTipColor("Black", "White") ; [b]<-- but then the font of the tooltip becomes too small for me to read.[/b]
	ToolTip, WRITE MODE, 0, 0
	Write_mode:=0
	}
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\quick zoom.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\B = Back to last stop and play.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\TimeLineClick-master\TimelineClick.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete start to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete end to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change transition length.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Create Cross Dissolve Transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Smooth Cut transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Dip to Color Dissolve Transition.ahk ahk_class AutoHotkey
Return
}

User avatar
SirSocks
Posts: 360
Joined: 26 Oct 2018, 08:14

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by SirSocks » 24 Sep 2020, 07:42

Very handy! Thank you!

Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by Gregorian » 26 Sep 2020, 07:30

Hey, it would be really nice if someone could tell me why this function doesn't work together with my script.
Again, if I change the font of the tooltip, my other functions stop working. What can I do?
I need a bigger tooltip with bigger font real bad, but I also need my other functions to work. :(

DMDComposer
Posts: 12
Joined: 14 Jul 2018, 18:55
Contact:

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by DMDComposer » 19 Apr 2021, 13:09

@Lexicos

Hi, I was wondering is it possible to make the tooltip borderless? Or, remove the color. At the moment, whatever I set the font color too will also make the border that color.

I tried adding

Code: Select all

Gui _TTG: -Caption
;--or----
Gui _TTG: -Border
To the TTG command but wasn't working.

Thoughts?

Cheers,
DMDComposer

AutomateThis
Posts: 1
Joined: 02 Jun 2021, 13:38

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by AutomateThis » 02 Jun 2021, 13:57

I just wanted to report this error.

I recently update AHK to 1.1.33.09. I think this coincided with me getting a fatal error. It is easy to replicate.

Code: Select all

#Include common_tooltip.ahk
ToolTipFont("s12","Arial")
ToolTipColor("blue","White")

!k::
  ToolTip, Test, 130, 100
  sleep 1000
  ToolTip
  Clipboard := "Test"
  return


The common_tooltip.ahk is just contains the code presented here. After the second AltK, the following error pops up:
Error in #include file common_tooltip.ahk:
SetClipboardData

060: return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
The cause is "Clipboard := Title" or setting it to anything. I have to do a Reload after Clipboard := to work around the error.

User avatar
Micromegas
Posts: 260
Joined: 28 Apr 2015, 23:02
Location: Germany

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by Micromegas » 09 Jul 2021, 05:51

I'm getting the same error as reported by AutomateThis and others before. But Reload is too drastic to be generally used as a workaround. Is there any solution in sight?

Spitzi
Posts: 301
Joined: 24 Feb 2022, 03:45

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by Spitzi » 08 Mar 2022, 16:52

Thanks for sharing!!

chaoscreater
Posts: 59
Joined: 12 Sep 2019, 21:15

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by chaoscreater » 28 Mar 2022, 23:28

AutomateThis wrote:
02 Jun 2021, 13:57
I just wanted to report this error.

I recently update AHK to 1.1.33.09. I think this coincided with me getting a fatal error. It is easy to replicate.

Code: Select all

#Include common_tooltip.ahk
ToolTipFont("s12","Arial")
ToolTipColor("blue","White")

!k::
  ToolTip, Test, 130, 100
  sleep 1000
  ToolTip
  Clipboard := "Test"
  return


The common_tooltip.ahk is just contains the code presented here. After the second AltK, the following error pops up:
Error in #include file common_tooltip.ahk:
SetClipboardData

060: return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
The cause is "Clipboard := Title" or setting it to anything. I have to do a Reload after Clipboard := to work around the error.

Having the exact same issue. If I'm using Clipboard := "blah", then it'll throw that error.

The weird thing is, this would only throw the error on the 2nd clipboard entry. So something like this:

Code: Select all

clipboard := "blah"
Send ^v	
sleep, 150

clipboard := "blah2"  ---> this is where it breaks
Send ^v	
sleep, 150
Aside from reloading, the other workaround that I found is to clear the clipboard after each paste, so it'll look like this:

Code: Select all

clipboard := "blah"
Send ^v	
sleep, 150
clipboard :=

clipboard := "blah2"  ---> this is fine now
Send ^v	
sleep, 150
clipboard :=

LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by LAPIII » 21 Apr 2022, 18:01

Might anyone know how to fix this:

Code: Select all

#SingleInstance, Force
#Include C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures   

^+PrintScreen::
WinGetPos, X, Y, W, H, A
Clipboard := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)

{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Clipboard)
Gdip_SaveBitmapToFile(snap, OutFile)
Gdip_DisposeImage(snap)		;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) 	;Turn off gdip
return
}

ToolTipFont("s14", "Comic Sans MS") 
ToolTipColor("green", "white")
ToolTip, Active Window Screenshot, 1525, 0
SetTimer, RemoveToolTip, 1000
return

RemoveToolTip:
ToolTip
return

; ToolTipOpt v1.004
 
ToolTipFont(Options := "", Name := "", hwnd := "") {
    static hfont := 0
    if (hwnd = "")
        hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
    else
        DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
 
ToolTipColor(Background := "", Text := "", hwnd := "") {
    static bc := "", tc := ""
    if (hwnd = "") {
        if (Background != "")
            bc := Background="Default" ? "" : _TTG("Color", Background)
        if (Text != "")
            tc := Text="Default" ? "" : _TTG("Color", Text)
        _TTHook()
    }
    else {
        VarSetCapacity(empty, 2, 0)
        DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
            , "ptr", (bc != "" && tc != "") ? &empty : 0)
        if (bc != "")
            DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
        if (tc != "")
            DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
    }
}
 
_TTHook() {
    static hook := 0
    if !hook
        hook := DllCall("SetWindowsHookExW", "int", 4
            , "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
            , "uint", DllCall("GetCurrentThreadId"), "ptr")
}
 
_TTWndProc(nCode, _wp, _lp) {
    Critical 999
   ;lParam  := NumGet(_lp+0*A_PtrSize)
   ;wParam  := NumGet(_lp+1*A_PtrSize)
    uMsg    := NumGet(_lp+2*A_PtrSize, "uint")
    hwnd    := NumGet(_lp+3*A_PtrSize)
    if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
        _hack_ = ahk_id %hwnd%
        WinGetClass wclass, %_hack_%
        if (wclass = "tooltips_class32") {
            ToolTipColor(,, hwnd)
            ToolTipFont(,, hwnd)
        }
    }
    return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
 
_TTG(Cmd, Arg1, Arg2 := "") {
    static htext := 0, hgui := 0
    if !htext {
        Gui _TTG: Add, Text, +hwndhtext
        Gui _TTG: +hwndhgui +0x40000000
    }
    Gui _TTG: %Cmd%, %Arg1%, %Arg2%
    if (Cmd = "Font") {
        GuiControl _TTG: Font, %htext%
        SendMessage 0x31, 0, 0,, ahk_id %htext%
        return ErrorLevel
    }
    if (Cmd = "Color") {
        hdc := DllCall("GetDC", "ptr", htext, "ptr")
        SendMessage 0x138, hdc, htext,, ahk_id %hgui%
        clr := DllCall("GetBkColor", "ptr", hdc, "uint")
        DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
        return clr
    }
}(-9|-9|1938|1048)

Because I get this:

TEST 2.ahk 4_21_2022 7_01_23 PM.png
TEST 2.ahk 4_21_2022 7_01_23 PM.png (22.28 KiB) Viewed 2815 times

User avatar
boiler
Posts: 16706
Joined: 21 Dec 2014, 02:44

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by boiler » 21 Apr 2022, 20:23

I told you how in the other thread. Don’t use the clipboard, use a regular variable, and declare it as global because you had a variable scope issue. I posted the fix. Did you try it?

LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Re: ToolTipFont / ToolTipColor - options for the ToolTip command

Post by LAPIII » 21 Apr 2022, 21:29

No it didn't work.

Post Reply

Return to “Scripts and Functions (v1)”