Problem with lexikos's ToolTipFont / ToolTipColor Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Lampshade
Posts: 58
Joined: 22 Apr 2016, 23:42

Problem with lexikos's ToolTipFont / ToolTipColor

06 Jul 2016, 02:58

https://autohotkey.com/boards/viewtopic.php?t=4777

For me, tooltips containing variables usually read "ahk_class tooltips_class32 ahk_id [idnumber]". Does anyone else get this?

Example:

Code: Select all

^e::
MouseGetPos, x, y, id, control
winGetpos, x2, y2,,,ahk_id %id%
WinGetPos,,,w, h, ahk_id %id%
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
PixelGetColor, color, %x%, %y%
WinGetActiveTitle, atitle
WinGetClass, aclass, A
if control =
    control := "No control found"
if title =
    title := "This window is untitled"
if atitle =
    atitle := "No title found"
ToolTipFont("s20", "Comic Sans MS")
ToolTip, %title%`nahk_class %class%`n%control%`nMouse: %x%`, %y%`nPos: %x2%`, %y2%`nSize: %w%`, %h%`n`nActive:`n%atitle%`nahk_class %aclass%`n%color%,,,2
return
lexikos
Posts: 6680
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Problem with lexikos's ToolTipFont / ToolTipColor  Topic is solved

06 Jul 2016, 03:54

That's the problem with hooking into places that the program doesn't expect. When the parameters are evaluated, the result is stored in the "deref buffer". Since the ToolTip command is not expecting to be interrupted, it does nothing to prevent the deref buffer from being reused by any thread that interrupts it. (The deref buffer is intended to be reused over and over, since it's purpose is to avoid having to allocate memory repeatedly for temporary strings.)

The expression "ahk_class tooltips_class32 ahk_id " hwnd puts its result into the deref buffer, overwriting ToolTip's parameter. That can be worked around by performing the concatenation into a variable, as in WinExist(_hack_ := " ... " hwnd). Then you will find that the tooltip shows its own HWND. This is because WinExist() returns a string (the HWND in hexadecimal form), so to avoid it, you must avoid WinExist(). In this case I only used it as a convenient way to check the class of the window in-line; you can use WinGetClass instead.

In theory, ahk_id %hwnd% used with SendMessage could cause the same problem, but doesn't seem to in your case.

I've updated the script (in my original post) with workarounds.
Lampshade
Posts: 58
Joined: 22 Apr 2016, 23:42

Re: Problem with lexikos's ToolTipFont / ToolTipColor

06 Jul 2016, 06:03

Fantastic thanks! However now TooltipColor isn't functioning right. ToolTipColor("Black", "White") used to create a black tooltip with white text but instead I get a white tooltip and the default text color..
lexikos
Posts: 6680
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Problem with lexikos's ToolTipFont / ToolTipColor

06 Jul 2016, 23:08

I added a bug in v1.003 and fixed it in v1.004.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], thenomad and 71 guests