System Theme Aware ToolTip (Dark/ Light Mode)

Post your working scripts, libraries and tools.
User avatar
NPerovic
Posts: 35
Joined: 31 Dec 2022, 01:25
Contact:

System Theme Aware ToolTip (Dark/ Light Mode)

Post by NPerovic » 25 Mar 2024, 17:00

This will make your ToolTip style conform to the current system theme (dark/ light mode and rounded corners on Win 11).


How It Looks Like (On Windows 11/ Dark Mode)
image.png
image.png (3.97 KiB) Viewed 310 times

How To Use
Just simply include this class in your script, and you're good to go!
No need to create an instance.

If you saved this class in your …\ScriptDir\lib folder.

Code: Select all

#Requires AutoHotkey v2 
#Include <SystemThemeAwareToolTip>
ToolTip "Zdravo!"
SetTimer ToolTip, -3000
If you saved this class in your …\ScriptDir folder.

Code: Select all

#Requires AutoHotkey v2 
#Include SystemThemeAwareToolTip.ahk
ToolTip "Zdravo!"
SetTimer ToolTip, -3000

Get the Code
On GitHub
Last edited by NPerovic on 10 Apr 2024, 15:02, edited 2 times in total.
✨ Dark Theme for Everything
✨ Other Scripts


iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Re: System Theme Aware ToolTip

Post by iamMG » 26 Mar 2024, 00:56

Nice script as always @NPerovic!

I am using ToolTipX script as a library. I found it here: viewtopic.php?p=515335#p515335.
Can you incorporate the system-aware feature in that as well?

Much appreciated.

Edit: Btw, I followed you on Github. :)

User avatar
NPerovic
Posts: 35
Joined: 31 Dec 2022, 01:25
Contact:

Re: System Theme Aware ToolTip

Post by NPerovic » 26 Mar 2024, 01:52

iamMG wrote:
26 Mar 2024, 00:56
Nice script as always @NPerovic!

I am using ToolTipX script as a library. I found it here: viewtopic.php?p=515335#p515335.
Can you incorporate the system-aware feature in that as well?

Much appreciated.

Edit: Btw, I followed you on Github. :)
Thanks:) It's great to hear that my script is being utilized!

Just simply incorporate SystemThemeAwareToolTip into your script library, and you're all set!

You can then use ToolTipX as you normally would.
✨ Dark Theme for Everything
✨ Other Scripts


iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Re: System Theme Aware ToolTip

Post by iamMG » 26 Mar 2024, 03:31

Thanks for the quick reply.

While browsing your Github, I came across ToolTipEx. I compared its code with the ToolTipX script I mentioned earlier, and found out that they are different.
Can you please tell which one is superior/superseded? Or do they serve different purposes?

iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Re: System Theme Aware ToolTip

Post by iamMG » 30 Mar 2024, 07:16

I compared how ToolTipEx and ToolTipX performed and found out that the former causes delays when called repeatedly, while the latter immediately updates the tooltip text, although the timeout is affected (it is not reset and gets reduced). Can you look into this?

Here's a script in which I am using ToolTipEx:

Code: Select all

#requires AutoHotkey v2.0 
#include <toolTipEX>
cycleNumber := 1

#c:: {
	global cycleNumber
	if (cycleNumber == 1)
		setTimer(cycleReset , -5000)
	caseConverter(mod(cycleNumber , 3))
	cycleNumber++
	setTimer(cycleReset)
}

caseConverter(caseNumber){
	;	release all keys if issue arises
	selection := getSelectedText() , selectionLength := strlen(selection)
	switch caseNumber {
		case 1:													;	CONVERT CLIPBOARD TO UPPER CASE
			send(Format("{:U}" , selection))
			toolTipEX("UPPER CASE" , 2)
		case 2:													;	Convert Clipboard To Title Case
			send(Format("{:T}" , selection))
			toolTipEX("Title Case" , 2)
		default:												;	convert clipboard to lower case
			send(Format("{:L}" , selection))
			toolTipEX("small case" , 2)
	}
	send("{Shift down}{left " selectionLength "}{Shift up}")	;	Highlight text
	return
}

cycleReset() {
	global cycleNumber
	cycleNumber := 1
	setTimer( , 0)
	toolTipEX("cycleNumber reset!" , 2)
	return
}

getSelectedText() {
	originalClipboard := ClipboardAll()
	a_Clipboard := ""
	sendEvent("{Ctrl down}{c}{Ctrl up}")
	clipWait()
	selectedText := a_Clipboard , a_Clipboard := originalClipboard , originalClipboard := ""
	return selectedText
}

User avatar
NPerovic
Posts: 35
Joined: 31 Dec 2022, 01:25
Contact:

Re: System Theme Aware ToolTip

Post by NPerovic » 30 Mar 2024, 13:35

iamMG wrote:
30 Mar 2024, 07:16
I compared how ToolTipEx and ToolTipX performed and found out that the former causes delays when called repeatedly, while the latter immediately updates the tooltip text, although the timeout is affected (it is not reset and gets reduced). Can you look into this?

Here's a script in which I am using ToolTipEx:

Code: Select all

#requires AutoHotkey v2.0 
#include <toolTipEX>
cycleNumber := 1

#c:: {
	global cycleNumber
	if (cycleNumber == 1)
		setTimer(cycleReset , -5000)
	caseConverter(mod(cycleNumber , 3))
	cycleNumber++
	setTimer(cycleReset)
}

caseConverter(caseNumber){
	;	release all keys if issue arises
	selection := getSelectedText() , selectionLength := strlen(selection)
	switch caseNumber {
		case 1:													;	CONVERT CLIPBOARD TO UPPER CASE
			send(Format("{:U}" , selection))
			toolTipEX("UPPER CASE" , 2)
		case 2:													;	Convert Clipboard To Title Case
			send(Format("{:T}" , selection))
			toolTipEX("Title Case" , 2)
		default:												;	convert clipboard to lower case
			send(Format("{:L}" , selection))
			toolTipEX("small case" , 2)
	}
	send("{Shift down}{left " selectionLength "}{Shift up}")	;	Highlight text
	return
}

cycleReset() {
	global cycleNumber
	cycleNumber := 1
	setTimer( , 0)
	toolTipEX("cycleNumber reset!" , 2)
	return
}

getSelectedText() {
	originalClipboard := ClipboardAll()
	a_Clipboard := ""
	sendEvent("{Ctrl down}{c}{Ctrl up}")
	clipWait()
	selectedText := a_Clipboard , a_Clipboard := originalClipboard , originalClipboard := ""
	return selectedText
}
I've updated the ToolTipEx.
Those issues you mentioned should be fixed now.
✨ Dark Theme for Everything
✨ Other Scripts


iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Re: System Theme Aware ToolTip

Post by iamMG » 31 Mar 2024, 04:12

NPerovic wrote:
30 Mar 2024, 13:35
I've updated the ToolTipEx.
Those issues you mentioned should be fixed now.
Thanks for the quick fix! It works perfectly now.

Post Reply

Return to “Scripts and Functions (v2)”