Page 1 of 1
Need to show tooltip when toggling Suspend
Posted: 29 Mar 2017, 09:33
by ry3ks3u_m4dd0ns
I'm working on a script that temporarily disables the number keys on top of the QWERTYUIOP, and it sort of works, just not the way I expected it to. Yes, the script gives me a tooltip and then suspends, but then it also closes itself.
Here's what I have so far.
Code: Select all
ScriptStat := false
Numpad0::
If ScriptStat
{
ScriptStat := false
Tooltip, Script reenabled.
Suspend
return
}
ScriptStat := true
Tooltip, Script suspended.
Suspend
Any help would be appreciated, and also all roasts on how I'm a scrub at this is also welcome.
Re: Need to show tooltip when toggling Suspend
Posted: 29 Mar 2017, 09:44
by evilC
Code: Select all
ScriptStat := false
Numpad0::
Suspend ; Make this hotkey immune to suspend, so it can Un-Suspend
If ScriptStat
{
ScriptStat := false
Tooltip, Script reenabled
Suspend, Off
} else {
ScriptStat := true
Tooltip, Script suspended.
Suspend, On
}
return
Re: Need to show tooltip when toggling Suspend
Posted: 29 Mar 2017, 09:51
by ry3ks3u_m4dd0ns
evilC wrote:Code: Select all
ScriptStat := false
Numpad0::
Suspend ; Make this hotkey immune to suspend, so it can Un-Suspend
If ScriptStat
{
ScriptStat := false
Tooltip, Script reenabled
Suspend, Off
} else {
ScriptStat := true
Tooltip, Script suspended.
Suspend, On
}
return
Thank you, evilC!
This helped a lot.
Re: Need to show tooltip when toggling Suspend Topic is solved
Posted: 29 Mar 2017, 10:20
by Nextron
Although the above fixes your code, there are some remarks:
•
Suspend is equivalent to
Suspend, Toggle, so you're already changing the suspend state and possible doing it again later in the code.
• There can be valid reasons to keep you own suspend state variable, but there is already a more reliable one built in:
A_IsSuspended.
So you can reduce and improve it to:
Code: Select all
Numpad0::
Suspend
ToolTip % A_IsSuspended ? "Script suspended" : "Script reenabled"
Return
Re: Need to show tooltip when toggling Suspend
Posted: 30 Sep 2022, 12:35
by AlFlo
I tried using Nextron's script in my AHK autocorrect script. It works to toggle suspend on/off, but doesn't create a tooltip. I also changed tooltip to msgbox, but it doesn't create a message box, either.
What am I doing wrong?
Re: Need to show tooltip when toggling Suspend
Posted: 01 Oct 2022, 13:39
by AlFlo
Never mind ... I figured it out:
Code: Select all
^y::
Suspend
ToolTip,% a_isSuspended?"Regular":"Autocorrect", 1400, 2800
SetTimer, RemoveToolTip, -2000
return
RemoveToolTip:
ToolTip
return