Script after suspend do not want to unsuspend

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Script after suspend do not want to unsuspend

01 Aug 2021, 18:20

I have problem with my code: When I click F6 key my script suspend and when I click it again it does not unsuspend. Also after clicking t key and after F6 key MsgBox don't work.

My idea was this: If I run secound label, first label can't work, after secound label is done, first label can work.

My code:

Code: Select all

global abc:=true
Firstlabel:
if(abc=true){
Suspend
ToolTip % A_IsSuspended ? "Script is off" : "", 400, 0
}
else{
MsgBox,, Script, ERROR
}
Return
;```````````````````````````````````````````````````````````````````````````````````````````
Secoundlabel:
~t::
Suspend On
abc:=false
Loop
if (GetKeyState("Enter", "P") || GetKeyState("Escape", "P"))
break
Suspend Off
abc:=true
return
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script after suspend do not want to unsuspend

02 Aug 2021, 01:48

Hallo,
try:

Code: Select all

Firstlabel:
Loop
{
	SoundBeep,% 500 + (A_TickCount & 0xFFF), 20
	ToolTip, first label is working
	Sleep, 200
}
Return
Secoundlabel:
~t::
While, !GetKeyState("Enter", "P") And !GetKeyState("Escape", "P")
{
	ToolTip, second label is working
	Sleep, 100
}
return
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Script after suspend do not want to unsuspend

02 Aug 2021, 11:40

Rohwedder wrote:
02 Aug 2021, 01:48
Hallo,
try:

Code: Select all

Firstlabel:
Loop
{
	SoundBeep,% 500 + (A_TickCount & 0xFFF), 20
	ToolTip, first label is working
	Sleep, 200
}
Return
Secoundlabel:
~t::
While, !GetKeyState("Enter", "P") And !GetKeyState("Escape", "P")
{
	ToolTip, second label is working
	Sleep, 100
}
return
Your code doesn't work properly and it don't work how I wanted, I write above how it should work, can you repair it ?
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script after suspend do not want to unsuspend

03 Aug 2021, 01:50

You wrote about a problem with a F6 key suspension and the idea:
If I run secound label, first label can't work, after secound label is done, first label can work.
Since your script did not contain the F6 key, I followed that the problem was already solved and just implemented your idea.
If you want to have an on/off suspension with F6 key add:

Code: Select all

*F6::Suspend
Suspend disables only Hotkeys and Hotstrings and can thus prevent threads from starting. It has no effect on already started threads.
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Script after suspend do not want to unsuspend

03 Aug 2021, 09:03

Rohwedder wrote:
03 Aug 2021, 01:50
You wrote about a problem with a F6 key suspension and the idea:
If I run secound label, first label can't work, after secound label is done, first label can work.
Since your script did not contain the F6 key, I followed that the problem was already solved and just implemented your idea.
If you want to have an on/off suspension with F6 key add:

Code: Select all

*F6::Suspend
Suspend disables only Hotkeys and Hotstrings and can thus prevent threads from starting. It has no effect on already started threads.
Ok but is it possible to make it something like that (this code don't work):

Code: Select all

*%ABCKey%::
Suspend
    ToolTip % A_IsSuspended ? "Skrypt wyłączony z użycia" : "", 400, 0
return
I tried add it to the label and then use hotkey but it work as my first code
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Script after suspend do not want to unsuspend

03 Aug 2021, 09:42

Rohwedder wrote:
03 Aug 2021, 01:50
You wrote about a problem with a F6 key suspension and the idea:
If I run secound label, first label can't work, after secound label is done, first label can work.
Since your script did not contain the F6 key, I followed that the problem was already solved and just implemented your idea.
If you want to have an on/off suspension with F6 key add:

Code: Select all

*F6::Suspend
Suspend disables only Hotkeys and Hotstrings and can thus prevent threads from starting. It has no effect on already started threads.
I had make this:

Code: Select all


Firstlabel:
Suspend
ToolTip % A_IsSuspended ? "Script is off" : "", 400, 0
return

SecoundLabel:
~t::
    Suspend On
    if (A_IsSuspended){
        Hotkey, %FirstKey%, FirstLabel, Off
        Loop
        if (GetKeyState("Enter", "P") || GetKeyState("Escape", "P"))
            break
    }
            Suspend Off
    else if (!A_IsSuspended)
        Hotkey, %FirstKey%, FirstLabel, On
return
But with this code is that problem, you click F6 everything works, you click t (run secound label), first label doesn't work (everythings fine), after secoundlabel is done if you want to click F6 and suspend script it work, unsuspend also work. But if script was suspended, and you run secound label you can use first label. How to prevent it? Do you now maybe?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 315 guests