Troubleshooting location of ToolTip...

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
kunkel321
Posts: 1194
Joined: 30 Nov 2015, 21:19

Troubleshooting location of ToolTip...

Post by kunkel321 » 19 May 2024, 11:52

I have this bit of code:

Code: Select all

If CaretGetPos(&mcx, &mcy)
	ToolTip "::" newTrig "::" newRepl, mcx-15, mcy+140, 6 ; <--- LOCATION of tooltip is set here.
Else
	ToolTip "::" newTrig "::" newRepl,,, 6
It's about line 207 of the code here.

The tooltip is designed to occasionally appear as I'm typing, so I don't want it to cover the text I'm currently typing. In theory, it should only ever appear when I'm typing, so CaretGetPos should always return mcx and mcy. While debugging, the tooltip always appears where it is supposed to (an inch or so below my typing), but sometimes while I'm typing at work, it will cover my text. I've increased the mcy+n value a couple of times but it keeps happening. I "think" I've ruled-out screen scaling issues. It's also noteworthy that I've embedded Just Me's Class ToolTip Options, but I don't believe that the problem is coming from there.

Actually... As I type this, it occurs to me that I can put a unique-sounding SoundBeep in the Else block. Like that's the only thing I can think of, is that occasionally the CaretGetPos is returning false, that so the ToolTip appears near my mouse cursor...

Can you think of other things that might cause the tooltip to appear in the wrong spot?? Please note that mcx and mcy do not appear anywhere in the code other than the two locations seen above.
ste(phen|ve) kunkel
User avatar
Noitalommi_2
Posts: 330
Joined: 16 Aug 2023, 10:58

Re: Troubleshooting location of ToolTip...

Post by Noitalommi_2 » 19 May 2024, 15:14

Hi.

Just wondering, could it be that the tool tip is hitting the edges of the screen or taskbar, causing the position to shift?
User avatar
kunkel321
Posts: 1194
Joined: 30 Nov 2015, 21:19

Re: Troubleshooting location of ToolTip...

Post by kunkel321 » 20 May 2024, 07:50

Noitalommi_2 wrote:
19 May 2024, 15:14
Just wondering, could it be that the tool tip is hitting the edges of the screen or taskbar, causing the position to shift?
It's a good thought, but no, I'm typically working in about the middle of my screen when it happens. I typically use my secondary monitor for typing, because the lower DPI makes it easier to see. (Not as HD.) It's also noteworthy that my main monitor is set with the scaling at 125%, and the secondary is at 100%. That causes scaling weirdness with some apps. Usually I can fix apps by adjusting the Compatibility tab in the Properties dialog. That's why I kept gradually increasing the value of mcy+n, but occasionally the thing still appears over my text.

For now, I've changed my Else statement to this:

Code: Select all

            Else {
               ToolTip "**Caret Not Found**`n::" newTrig "::" newRepl,,, 6
Now I can at least diagnose if that is what's causing the tooltip to appear in strange places.

I will reply again with more info after I've seen the glitch a few times.
ste(phen|ve) kunkel
User avatar
andymbody
Posts: 996
Joined: 02 Jul 2017, 23:47

Re: Troubleshooting location of ToolTip...

Post by andymbody » 20 May 2024, 20:36

I haven't tested, but coordMode issue maybe? After a brief glance, I see no reference to coordMode in your code, and this usually messes mine up too.

Update: After browsing the rest of the topics, I see you may have been testing this theory already... did it resolve this issue?
User avatar
kunkel321
Posts: 1194
Joined: 30 Nov 2015, 21:19

Re: Troubleshooting location of ToolTip...

Post by kunkel321 » 21 May 2024, 12:19

andymbody wrote:
20 May 2024, 20:36
I haven't tested, but coordMode issue maybe? After a brief glance, I see no reference to coordMode in your code, and this usually messes mine up too.
Update: After browsing the rest of the topics, I see you may have been testing this theory already... did it resolve this issue?
I think this may have resolved it. I added this to the code:

Code: Select all

CoordMode 'ToolTip', 'Screen'
CoordMode 'Caret', 'Screen'
I've logged maybe 10 manual typing corrections, and they've all appeared in the expected location.

An interesting side note: Using this code:

Code: Select all

CoordMode 'ToolTip', 'Screen'
CoordMode 'Caret', 'Screen'

!^q::
{
   If CaretGetPos(&mbx, &mby)
      msgbox 'caret Pos ' mbx 'x, ' mby 'y'
   else
      MsgBox 'no caret 4 U'
}
I find that neither VSCode, nor Chrome edit fields ever return a caret position... MS Word always does though... And that's were I type most of my prose.
ste(phen|ve) kunkel
User avatar
kunkel321
Posts: 1194
Joined: 30 Nov 2015, 21:19

Re: Troubleshooting location of ToolTip...

Post by kunkel321 » 30 May 2024, 14:26

This issue of the tooltip covering up what I'm typing happened again today. Interestingly, experimenting showed that it was only happening when typing in Word, and then the caret/typing is near the bottom of my screen. Using Notepad near the bottom, OR moving the Word window up near the top of the monitor fixed it, but if I moved the Word window to the bottom, the problem came back.

I find that if something gets "offset" more, the closer it is to the edge of the screen, then it is often an app scaling issue. But would the app scaling settings of Word vs Notepad affect where the tooltip from my AHK app appears?? It doesn't seem like it would.
ste(phen|ve) kunkel
Post Reply

Return to “Ask for Help (v2)”