Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[SOLVED] ToolTip which follows the mouse Juddery


  • Please log in to reply
9 replies to this topic
Cephei1
  • Members
  • 396 posts
  • Last active: Jan 22 2014 08:19 PM
  • Joined: 04 Aug 2008
Hi,

I use the following code to have the tooltip to follow the mouse and auto close after a specified period:

ToolTipDisp(Data,Time)
{
	global
	Info:= Data
	SetTimer, ToolTipDisplay, 10
	If Time > 0
		SetTimer, ToolTipDisplayOff, %TIME%
}

ToolTipDisplayOff:
SetTimer, ToolTipDisplayOff, Off
SetTimer, ToolTipDisplay, Off
Time:= "", Info:= ""
Tooltip
Return

ToolTipDisplay:
ToolTip, %Info%
Return
Problem im having is that if it has allot of information about 200-300 characters, it judders and flashes whilst its displayed.

I use it to display the song name from Spotify when it changes like so:

ENTIRE CODE:
#Persistent
#SingleInstance, Force
Settimer, SpotifyTitle, 1000
Return

SpotifyTitle:
Process, Exist, Spotify.exe
If ErrorLevel > 0
{
	WinGetTitle, TitleWin, ahk_class SpotifyMainWindow
	If TitleWin Contains Spotify - 
	{
		TitleWin:= RegExReplace(TitleWin,"Spotify - ","")
		WinSetTitle, Spotify,, %TitleWin%
		ToolTipDisp("_  _ __ ___ ___| Now Playing |____ ___ __ _ _  _   _    _     _`n"TitleWin,"5000")
	}
}
Return

ToolTipDisp(Data,Time)
{
	global
	Info:= Data
	SetTimer, ToolTipDisplay, 10
	If Time > 0
		SetTimer, ToolTipDisplayOff, %TIME%
}

ToolTipDisplayOff:
SetTimer, ToolTipDisplayOff, Off
SetTimer, ToolTipDisplay, Off
Time:= "", Info:= ""
Tooltip
Return

ToolTipDisplay:
ToolTip, %Info%
Return

Is there a way to stop the text flashing/juddering?

Thanks,
Dabs

Ahk_L (Unicode 32-bit)


MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Display the tooltip once, retrieve its ID/handle (hwnd) and use a timer to WinMove it around.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


DABS
  • Guests
  • Last active:
  • Joined: --
Sounds good. Ill try that.

Thanks.

DABS
  • Guests
  • Last active:
  • Joined: --
Ok here it is. This is a test, this should replace most of the above ToolTipDisp() function I wrote

#Persistent
ToolTip, This is a Test. And it works!
ControlGet, TTHWND, HWND,,,ahk_class tooltips_class32
SetTimer, EE, 10
Return

EE:
Coordmode, ToolTip, Screen
Coordmode, Mouse, Screen
MouseGetPos,X,Y
WinMove, ahk_id %TTHWND%,,% x+10,% y+20
Return

Is this how you mean MasterFocus?

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Yeah, probably. Didn't you test? I can't test right now (I'm on Linux here).
I'd personally use WinGet instead of ControlGet.
Also, both of your CoordMode calls can go right after #Persistent.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


DABS
  • Guests
  • Last active:
  • Joined: --
Yes I've tested it. It works.

The juddery thing I mentioned above has stopped.

Just wondering. Is there a way to speed up the set timer? so that the Tooltip movement is smooth?

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
"Smooth"? Well, I remember using 25 or 50 is usually better than 10 or 'On'.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
use
SetWinDelay, 0
See also: [AHL_L+H] TT() - Full-blown ToolTip Library by HotKeyIt

DABS
  • Guests
  • Last active:
  • Joined: --
This worked great as you mentioned Learning one:
SetWinDelay, 0

Thank you MasterFocus and Learning One

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
On my way home, I remembered about SetWinDelay. :)
Glad it worked.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.