ToolTipAll

Post your working scripts, libraries and tools
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

ToolTipAll

02 Dec 2017, 11:14

After almost one year using ToolTipFont for this purpose I switched to Fnt library and I think it is worth of a new thread! Now it shouldn't affect other processes and is more reliable.
It won't truncate ToolTip text in some Apps anymore.
It will set user defined Font size (and optionally Font type) to the standard ToolTips (Ahk's, OS's & other Apps) shown on the screen.
Generally it won't change AutoHotkey's ToolTip(s) already changed by their scripts. If such script is using Fnt library Sleep -1 after ToolTip some text seems to help, preventing ToolTipAll of making changes again.

Code: Select all

#NoEnv
#SingleInstance Force
;~ #Persistent
SetBatchLines, -1
global Tt_Update, hFont, UnhkWE, GlobF

HookProcAdr := RegisterCallback( "HookProc", "F" )
hWinEventHook := SetWinEventHook( 0x8002, 0x8002, 0, HookProcAdr, 0, 0, 0) ; 0x8002 show events 
OnExit, HandleExit
Return

;Based on Serenity's hook https://autohotkey.com/board/topic/32662-tool-wineventhook-messages/
HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime ) {
	WinGetClass, class, ahk_id %hWnd%
	If (class = "tooltips_class32")	{
		if !Tt_Update {
			if !hFont
				hFont:=Fnt_CreateFont("", "s16") ;set the font size (and optionally font type)
			Tt_Update:= 1
			SendMessage 0x30, hFont, 0,, ahk_id %hwnd% ; 0x30 WM_SETFONT
			SendMessage 0x418, 0, 800,, ahk_id %hwnd% ; 0x418 TTM_SETMAXTIPWIDTH
			SendMessage 0x41D, 0, 0,, ahk_id %hwnd% ; 0x41D TTM_UPDATE
		}
		SetTimer, ResetTt_Update, -0
	}
}

ResetTt_Update:
	Tt_Update:= ""
return

SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags) {
	DllCall("CoInitialize", Uint, 0)
	return DllCall("SetWinEventHook"
	, UInt, eventMin
	, UInt, eventMax
	, Ptr, hmodWinEventProc
	, Ptr, lpfnWinEventProc
	, UInt, idProcess
	, UInt, idThread
	, UInt, dwFlags
	, Ptr)
	
}

UnhookWinEvent() {
	Global
	UnhkWE:= DllCall( "UnhookWinEvent", Ptr, hWinEventHook )
	;GlobF:= DllCall( "GlobalFree", Ptr, &HookProcAdr, Ptr ) ; free up allocated memory for RegisterCallback
}

+Esc::
!F2::
HandleExit:
	if hTTFont
		Fnt_DeleteFont(hTTFont)
	UnhookWinEvent()
	if (A_ThisLabel = "!F2")
		Reload
	 ExitApp
Return

; jballi's https://autohotkey.com/boards/viewtopic.php?f=6&t=4379&hilit=fnt+fonts
#Include, C:\Users\RRR\My Ahk-s\Fnt\Fnt.ahk
First Post
Known Limitations:
  • Changed ToolTip will be shown with underlined Font. (Can't get rid of it, but let's see it form a positive side: from a distance underlined text is easier to follow!)
  • Probable memory leakage at exiting the script. AFAIK negligible.
Attachments
ToolTipAll.png
ToolTipAll.png (55.96 KiB) Viewed 4800 times
Last edited by rommmcek on 21 Oct 2019, 22:15, edited 17 times in total.
Helgef
Posts: 4440
Joined: 17 Jul 2016, 01:02
Contact:

Re: ToolTipAll

04 Dec 2017, 14:04

Cool, it seems to work very well, even after I closed the script :lol:.

Thanks for sharing, cheers :xmas:
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

05 Dec 2017, 15:20

it seems to work very well, even after I closed the script
Not in Explorer & Explorer like dialogs (ahk_class CabinetWClass, ahk_class #32770), otherwise I think OS cashes the script in some apps, but not for ever!
Helgef
Posts: 4440
Joined: 17 Jul 2016, 01:02
Contact:

Re: ToolTipAll

05 Dec 2017, 15:34

It only stuck for the applications it applied to ofc. It will go away when the applications restart. It is stuck on my browser still, I could restart it but I'm starting to like it :lol:

Cheers.
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

06 Dec 2017, 05:18

My effort to prevent memory leak and increase efficiency was barren! Now I hope I got it right!
Last edited by rommmcek on 09 Dec 2017, 19:09, edited 1 time in total.
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: ToolTipAll

08 Dec 2017, 08:36

You should review the code and perform necessary changes for x64 support, namely using "UPtr" instead of "UInt" where required. ;)
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

09 Dec 2017, 11:37

Thanks for reviewing the code. Obviously I'm an ignorant amateur. This is probably 5 min task for a Pro, but for me it'll take a lot of researching and comparison. However, since I didn't detect any significant problem on x64 machine & Ahk, I won't hurry.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: ToolTipAll

09 Dec 2017, 14:03

- I've been working on this to help clean up DllCall lines:
[contains a list of numerous dll functions with parameter info]
DllCall converter/cleaner (e.g. x32 to x64/x32 two-way compatible) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=31365
[contains an extensive list of dll functions, sizes of parameters are usually correct, but not necessarily whether they are signed/unsigned][the return parameters are usually correctly identified as signed/unsigned]
WinApi
https://hotkeyit.github.io/v2/docs/commands/WinApi.htm
- Also useful:
AutoHotkey_MSDN_Types/Windows_Data_Types.txt at master · jNizM/AutoHotkey_MSDN_Types · GitHub
https://github.com/jNizM/AutoHotkey_MSD ... _Types.txt
- I'll add this to one of my tutorials, or start a new one.

- Here are some corrections for DllCall parameters.

Code: Select all

;handles to things, and pointers to things are usually Ptr.

	DllCall("CoInitialize", Ptr,0)

	return DllCall("SetWinEventHook"
	, UInt,eventMin
	, UInt,eventMax
	, Ptr,hmodWinEventProc
	, Ptr,lpfnWinEventProc
	, UInt,idProcess
	, UInt,idThread
	, UInt,dwFlags
	, Ptr)

	DllCall( "UnhookWinEvent", Ptr,hWinEventHook )

	DllCall( "GlobalFree", Ptr,&HookProcAdr, Ptr )
- Basically by checking the definitions for dll functions in MSDN, and gaining familiarity with parameter types, you learn how to correctly assign parameter types for DllCall and when creating structs. Structs are a bit harder because you need to understand about padding, e.g. certain parameters of size n can only start at offsets that are a multiple of n, and the overall size of structs is a multiple of certain parameter sizes.
- We try our best, it's still feasible that I've made errors here or elsewhere, however, I now use automated scripts based on heavily checked lists to help me out.
Last edited by jeeswg on 10 Dec 2017, 12:11, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

09 Dec 2017, 18:48

Thanks, very generous!
First two Ptr-s of the SetWinEventHook would I probably guess. I mean guess. The last one never! Yes I often check MSDN, but I don't know C!

P.s.: Thanks for links, and very extensive work of yours!
P.p.s.: I noticed only now. Drugwash suggested UPtr-s. I have no clue!
Last edited by rommmcek on 11 Dec 2017, 12:05, edited 1 time in total.
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: ToolTipAll

10 Dec 2017, 06:01

Unsigned Pointer (UPtr) works only where the variable is certain to have valid positive value. When manually feeding a known value to a function you can use UPtr. Otherwise use Ptr which can take either positive or negative value, depending - for example - on the output of another command/function/API.
For safety you can always use Ptr instead of UPtr.

In x64, pointers have 64bit values so when truncating them to 32bit values by using Int/UInt it's likely to encounter errors. AHK knows how to cast Ptr and UPtr to 32bit/64bit according to the AHK version used.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

10 Dec 2017, 12:03

Thanks for tutorial...
However today wasn't my happy day. The whole day my version of ClipJump almost didn't work. Now I switched back in ToolTipAll to UInt and it works as it should again.
P.s.: Link above is for original version.

Edit: Inserting Ptr-s to ToolTipAll does not make ClipJump to fail!
Last edited by rommmcek on 11 Dec 2017, 01:07, edited 1 time in total.
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: ToolTipAll

10 Dec 2017, 15:55

There may still be issues in the Font library and/or in your version of ClipJump that clash with this script. You need to thoroughly check and debug all of them.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

11 Dec 2017, 01:03

Sorry for the wrong report! ToolTipAll seems to work fine without any undesired interactions (w or w/o Ptr-s).
The culprit for my trouble was interaction between ScreenClipping and ClipJump.
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: ToolTipAll

11 Dec 2017, 02:18

No worries, glad you sorted out the issue. :)

[EDIT] For what it's worth, font is fine on my 32bit XP-SP3 - no underline or other issues.
I've added an OnExit, HandleExit command to the autoexec section so when closing the script from the tray menu it'd still remove the hook.
Also modified Fnt_CreateFont() by adding a q5 (ClearType) to parameters string although I don't see any visible improvement (q4 wasn't of much help either).
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

11 Dec 2017, 12:02

Thanks once again for OnExit, HandleExit.
With ClearType I won't bother since even you don't report much improvement.
Update in OP.

bye!
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: ToolTipAll

11 Dec 2017, 12:52

You're welcome. :)

A probably desired improvement may be restoring tooltip font data on script exit. That may be achieved by retrieving each tooltip window's font data, storing it and restoring it on script exit, if user so chooses. That may require the use of an array.

You could also improve this script by allowing users to choose their desired font typeface/size/quality/etc in a GUI. ;)
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

15 Oct 2019, 02:56

Updated the code in OP to be more efficient and to prevent flickering in some windows.

@Drugwash: Don't remember to read your last post. First part is probably too complicated for me and the second part, well, I'm doing it in the code directly, but if you insist, I'll do it when I find some more time.
bye!
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: ToolTipAll

16 Oct 2019, 03:36

I can't even remember typing it (or what your script is about). It's been almost two years apparently, a lot has happened in the mean time, such as me switching to Linux with all the hurdles involved. So... yeah, don't cling too much on my opinions. ;)
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
rommmcek
Posts: 1007
Joined: 15 Aug 2014, 15:18

Re: ToolTipAll

16 Oct 2019, 08:20

It's easier for me to remember something about this topic (since I wrote the code and am using it non stop), but I'm still very grateful for your help!

P.s.: Only recently I confirmed my suspicion that the script doesn't exit properly (i.e. process remains in memory and killing it just suspend it freeing some but not all of occupied memory). To fix it I'll certainly need external help (not necessary form you)!
Until than I'll add further limitations in OP.
P.p.s.: Linux, yeah! That would be my intimate choice too, but I heavily depend on AutoHotkey, so until there is no AutoHotkey for Linux I'll have to stick unfortunately with Windows.
Last edited by rommmcek on 20 Oct 2019, 21:45, edited 1 time in total.
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: ToolTipAll

17 Oct 2019, 06:42

Unfortunately I haven't been able to code for quite some time, partly due to Linux being pig-headed, partly due to problems with my cats and kittens. Little spare time left. Hopefully someone would offer you their help for this script.

As mentioned in some other topic, AHK works partly under Linux/Wine but no hotkeys, no hotstrings, no interaction with Linux native GUIs, and a few visual glitches too. I do run some of my own scripts daily though. It all depends on what you're attempting to achieve.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: DuyMinh and 30 guests