@arcticir: Probably with TTM_SETMAXTIPWIDTH.
@rommmcek: Thanks for reporting the bug; I've fixed it.
I suppose you can simply use WinGetPos to get the dimensions of the tooltip.
ToolTipFont / ToolTipColor - options for the ToolTip command
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
About TTM_SETMAXTIPWIDTH, Can you provide an example?
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
@arcticir Try this? untested.
Code: Select all
TT_SetMaxWidth(MaxWidth := -1, hwnd := "") {
; see https://msdn.microsoft.com/library/bb760408
WM_USER := 1024
TTM_SETMAXTIPWIDTH := (WM_USER+24)
SendMessage, %TTM_SETMAXTIPWIDTH%, 0, %MaxWidth%, , ahk_id %hwnd%
return %ErrorLevel%
}
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]
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
Joedf, thanks. I use a different method, solved the problem.
https://autohotkey.com/boards/viewtopic ... 28&t=20192
https://autohotkey.com/boards/viewtopic ... 28&t=20192
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
It seems that I solved occasional broken display reported 07/06/16.
I use sleep, 0 or sleep, -1 before return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
P.s.: Obviously I missed your answer:
I use sleep, 0 or sleep, -1 before return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
P.s.: Obviously I missed your answer:
Yes, this is after displaying! What about beforehand?I suppose you can simply use WinGetPos to get the dimensions of the tooltip.
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
I have been using the Fnt library for this. It has functions that return size given the text you want to display. https://autohotkey.com/boards/viewtopic.php?t=4379Yes, this is after displaying! What about beforehand?
Relayer
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
@Relayer: Thanks, after initial trouble I started to like it! I even made a small contribution: https://autohotkey.com/boards/viewtopic ... 31#p128531
@lexikos: As much as I like ToolTipFont for it's simplicity to update old scripts, it seems that it's suitable only for simple code.
I've isolated three issues I encountered, two of them easily to reproduce!1. SendMessage inhibited.
2. Assigning to Clipboard make the script crash.
P.s.: These issues don't appear if running ToolTipFont functions from another script, however simplicity is obviously lost.
@lexikos: As much as I like ToolTipFont for it's simplicity to update old scripts, it seems that it's suitable only for simple code.
I've isolated three issues I encountered, two of them easily to reproduce!
Code: Select all
#NoEnv
#Warn
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
#include, TooltipFont.ahk
;~ #include, Fnt.ahk
ToolTipFont("s32", "Magneto")
ToolTipColor("c0ffc0", "800080")
EText := "Madrugada"
Gui, font, s14
Gui, Add, Edit, xm w175
Gui, Add, Button, y+m gBLabel, Show ToolTipFont
Gui, Show, x300, Window
ControlSend,, {Tab}, Window ahk_class AutoHotkeyGUI
Return
GuiEscape:
GuiClose:
ExitApp
return
BLabel:
;gui Submit,NoHide
ControlSetText, Edit1, % "", Window ahk_class AutoHotkeyGUI ;works
ToolTip, Hello ToolTipFont!, -250, 345
;~ ToolTipFnt("s32", "Magneto")
sleep, 1000
Msgbox Cancel_ToolTipFont & Set_Text`nTo Edit_Control !
Clipboard:=""
Clipboard:=EText
ClipWait
;ToolTip
;sleep, 500
;~ SendMessage, 0xC, , "Anochecer", Edit1, Window ahk_class AutoHotkeyGUI ;doesn't work
SendMessage, 0xC, , &EText, Edit1, Window ahk_class AutoHotkeyGUI ;doesn't work
;~ ControlSetText, Edit1, % EText, Window ahk_class AutoHotkeyGUI ;works
Sleep, 500
ToolTip
return
exitapp
2. Assigning to Clipboard make the script crash.
3. Dialogs display blank if mouse cursor is off field where they appear or off field of script's Gui if visible (not allways reproducible, see pic.)---------------------------
Limitations 4 TTF.ahk
---------------------------
Error in #include file "TooltipFont 1.005.ahk":
SetClipboardData
059: } Sleep,- 1
---> 060: Return,DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
061: }
The current thread will exit.
---------------------------
OK
---------------------------
P.s.: These issues don't appear if running ToolTipFont functions from another script, however simplicity is obviously lost.
- Attachments
-
- Limitations 4 TTF.png (90.72 KiB) Viewed 11179 times
Last edited by rommmcek on 04 Feb 2017, 08:05, edited 1 time in total.
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
I just had a surreal idea, what about Third Part Application ToolTips?
Using Serenity's functions & this very handy ToolTipFont by lexikos I got some success, however ToolTips in Explorers Control DirectUIHWND3 are updated only if triggering of the next ToolTip (form the same Control) occurs in less then circa 300 ms after pervious one (being still displayed).P.s.: Any improvements are appreciated!
Using Serenity's functions & this very handy ToolTipFont by lexikos I got some success, however ToolTips in Explorers Control DirectUIHWND3 are updated only if triggering of the next ToolTip (form the same Control) occurs in less then circa 300 ms after pervious one (being still displayed).
Code: Select all
#NoEnv
#SingleInstance Force
#Persistent
DetectHiddenWindows, On
DetectHiddenText, On
ToolTipFont("s16")
HookProcAdr := RegisterCallback( "HookProc", "F" )
hWinEventHook := SetWinEventHook( 0x8000, 0x8003, 0, HookProcAdr, 0, 0, 0 ) ; create, destroy, show and hide events
Return
#Include, C:\Users\RRR\My Ahk-s\ToolTipFont.ahk
HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
{
if Event
{
WinGetClass, class, ahk_id %hWnd%
If (class = "tooltips_class32")
ToolTipFont(,, hwnd)
}
}
SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
{
DllCall("CoInitialize", Uint, 0)
return DllCall("SetWinEventHook"
, Uint,eventMin
, Uint,eventMax
, Uint,hmodWinEventProc
, Uint,lpfnWinEventProc
, Uint,idProcess
, Uint,idThread
, Uint,dwFlags)
}
UnhookWinEvent()
{
Global
DllCall( "UnhookWinEvent", Uint,hWinEventHook )
DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
}
+Esc::
HandleExit:
UnhookWinEvent()
ExitApp
Return
!F2::
SoundBeep, 800, 300
UnhookWinEvent()
Reload
return
- Attachments
-
- ToolTipAll.png (50.55 KiB) Viewed 11080 times
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
After almost one year using ToolTipFont for ToolTipAll now I switched to Fnt library! It shouldn't affect other processes and is more reliable.
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
I'd expected to see this natively in v2, but nope! I'll try to get it working...
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
I have a ToolTip class for AHK v2, maybe you're interested, it's in the forum in Spanish but it includes an example. Personally I think it should be implemented natively in the versión 2. I created this class based on GuiControlTips by just me, all credits for him..chegr wrote:I'd expected to see this natively in v2, but nope! I'll try to get it working...
https://github.com/flipeador/Library-Au ... oolTip.ahk
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
Just starting to learn AHK. How do I use this script? Do I compile the code and then put ToolTipColor("Black", "White") in my script?
Tried that and it didn't work. Any suggestions?
Tried that and it didn't work. Any suggestions?
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
The example script provided here is a good place to start
https://autohotkey.com/boards/viewtopic ... 472#p27472
https://autohotkey.com/boards/viewtopic ... 472#p27472
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]
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
This has been working well, but recently I tried to use it with this script Sets of hotkeys and I got SetClipboardData error.
Like in this test script. Try using Ctrl+G several times for copying text.
Like in this test script. Try using Ctrl+G several times for copying text.
Code: Select all
#SingleInstance force
/*
Error: SetClipboardData
---> 076: Return,DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
*/
ToolTipFont("s9 w400", "Tahoma")
ToolTipColor("FAFAEE", "000000")
return
~^g:: Gosub, test
test:
last_clipboard = %clipboard%
last_clipboard:=Trim(last_clipboard)
Send, ^c
clipboard:=Trim(clipboard)
clipboard = %last_clipboard%` %clipboard%
ToolTip, % clipboard
return
ToolTipFont(Options := "", Name := "", hwnd := ""){ ;lexikos https://autohotkey.com/boards/viewtopic.php?t=4777
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")
}
; error SetClipboardData
_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
}
}
Close:
Esc::
ExitApp
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
How fast are you pressing Ctrl+G between each interval?
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]
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
@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.
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.
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
I get that error too - I tried to add this to my CL3 clipboard script for the "cycle through history" tooltips but when releasing the key that would assign the chosen text to the clipboard and paste it this error shows up.
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
@flipeador, thanks for that class! Here's a first shot at a translation into English. If you get a chance to make sure it's at least close to correct, I'd really appreciate it.
burque505
Spoiler
Regards,burque505
Re: ToolTipFont / ToolTipColor - options for the ToolTip command
@burque505 Looks good. Anyway I'm not good at writing documentation, I'm always discontent and I rewrite everything (the same happens to me with the coding style).