Issues unsuspending script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
icyolive
Posts: 3
Joined: 09 Apr 2024, 10:39

Issues unsuspending script

Post by icyolive » 15 Apr 2024, 08:16

Hello,

I'm trying to get this script going to suspend and unsuspend some hotkeys but it's not working in a very odd way.
After running the script I am able to suspend the script using the hotkey once, then it doesn't work. Then, if I manually unsuspend the script and use the hotkey to suspend it gives me the message "Script unsuspended!" even though it already was unsuspended. After that I can press the hotkey to suspend one more time and it doesn't work after that again.

Help would be appreciated, thanks.

Code: Select all

; Hotkey to toggle suspension
^+`::
    if (ScriptSuspended) {
        ; If the script is currently suspended, unsuspend it
        Suspend, Off
        ScriptSuspended := false
        MsgBox, Script unsuspended!
    } else {
        ; If the script is not suspended, suspend it
        Suspend, On
        ScriptSuspended := true
        MsgBox, Script suspended!
    }
return

*Space::LButton
*RALT::Space
*RCtrl::MButton
Up::Send {WheelUp}
Down::Send {WheelDown}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]

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

Re: Issues unsuspending script  Topic is solved

Post by mikeyww » 15 Apr 2024, 08:42

Hello,

When you suspend your hotkeys, the hotkeys can no longer be triggered-- with one exception.

Code: Select all

#Requires AutoHotkey v1.1.33.11
^+`:: ; Hotkey to toggle suspension
Suspend
If A_IsSuspended
     MsgBox 48, Status, Suspended!
Else MsgBox 64, Status, Not suspended.
Return
Any hotkey/hotstring subroutine whose very first line is Suspend (except Suspend On) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows suspension to be turned off via such a hotkey.
Source: Suspend - Syntax & Usage | AutoHotkey v1

icyolive
Posts: 3
Joined: 09 Apr 2024, 10:39

Re: Issues unsuspending script

Post by icyolive » 16 Apr 2024, 10:31

This works, thanks so much! Copilot wasn't even able to fix this.

RussF
Posts: 1270
Joined: 05 Aug 2021, 06:36

Re: Issues unsuspending script

Post by RussF » 16 Apr 2024, 11:44

How about that @mikeyww?!? Who would have thought that your real intelligence would overshadow artificial intelligence? I guess all the time and effort you've spent learning AHK has finally paid off.

Oops, gotta run - Copilot is telling I have to use the bathroom...

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

Re: Issues unsuspending script

Post by mikeyww » 16 Apr 2024, 11:48

Funny! AI needs more work.... :)

Post Reply

Return to “Ask for Help (v1)”