Tooltip closes early sometimes Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Tooltip closes early sometimes

Post by imkira3 » 28 Jan 2023, 18:44

The title pretty much says it all, the tooltip is supposed to close after 10 seconds, but about a quarter of the time it closes early and I can't figure out why, I'm sure my syntax is perfect

Code: Select all

; Settings

A_NumLock := "NumLock`rCtrl = Pause`rWin = Control Panel (System)`rAlt = Process Explorer"
A_TooltipDelay := "10000"
A_TooltipX := "0"
A_TooltipY4 := "-59"

; Basic Functions

<^NumLock::pause
<!NumLock::numpadclear
<#NumLock::#pause
<+NumLock::{
WinActivate "ahk_class" "Shell_TrayWnd"
ToolTip A_NumLock, A_TooltipX, A_TooltipY4
Sendinput "!{Esc}"
}

; Tooltip Timer

SetTimer () => ToolTip(), A_TooltipDelay

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Tooltip closes early sometimes  Topic is solved

Post by swagfag » 28 Jan 2023, 19:44

change it to

Code: Select all

<+NumLock::{
WinActivate "ahk_class" "Shell_TrayWnd"
ToolTip A_NumLock, A_TooltipX, A_TooltipY4
Sendinput "!{Esc}"
SetTimer () => ToolTip(), -A_TooltipDelay
}

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Tooltip closes early sometimes

Post by imkira3 » 28 Jan 2023, 20:03

Oh wow that worked nicely, thanks! Now I just need to figure out why !{Esc} isn't switching back to the previous app. It works sometimes, but sometimes not. It's very odd

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Tooltip closes early sometimes

Post by imkira3 » 28 Jan 2023, 20:13

Its supposed to shift to taskbar, do tooltip, then switch back to whatever app you had focus on

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Tooltip closes early sometimes

Post by imkira3 » 28 Jan 2023, 20:18

Ok so it turns out it doesn't switch back to windows marked as "On Top"

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Tooltip closes early sometimes

Post by imkira3 » 28 Jan 2023, 20:57

Hmmm so Alt+Tab switches back to the previous window if it's marked as on top, as the on top function has an effect on the order of apps in the Alt+Tab menu, but usually I would want to use Alt+Esc. I might have to try and make some kind of if based on whether or not the currently selected window is on top, if it's even possible for AHK to detect such a thing. Either that or I will have to try using a completely different method for switching windows

User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Tooltip closes early sometimes

Post by mikeyww » 28 Jan 2023, 22:02

WinActivate is a great choice. An example is on line 14 of your script.

Code: Select all

#Requires AutoHotkey v2.0
originalWindow := WinActive("A")
Run 'notepad'
Sleep 1500
SoundBeep 1500
WinActivate originalWindow

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Tooltip closes early sometimes

Post by imkira3 » 28 Jan 2023, 23:50

mikeyww wrote:
28 Jan 2023, 22:02
WinActivate is a great choice. An example is on line 14 of your script.

Code: Select all

#Requires AutoHotkey v2.0
originalWindow := WinActive("A")
Run 'notepad'
Sleep 1500
SoundBeep 1500
WinActivate originalWindow
Wow, it's perfect! Exactly what I needed to finish my script, thanks

Post Reply

Return to “Ask for Help (v2)”