How to make a script toggle from pressing a key?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

How to make a script toggle from pressing a key?

Post by Mandit_Gamer » 21 Aug 2021, 02:35

Is it possible to do like if I press *r* it toggles the script file? [It would be usefull as I need to toggle at different places quickly]

braunbaer
Posts: 483
Joined: 22 Feb 2016, 10:49

Re: How to make a script toggle from pressing a key?

Post by braunbaer » 21 Aug 2021, 04:30

What do you mean with "toggle the script"?

If you want to toggle a specific hotkey, for example f1, you can write

Code: Select all

f1Active:=true

#if f1Active
f1::  Msgbox F1 was pressed
#if
Now you can use say f2 to toggle f1:

Code: Select all

f2:: f1Active:=not f1Active

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: How to make a script toggle from pressing a key?

Post by Mandit_Gamer » 21 Aug 2021, 04:35

also wat is the default one to toggle it?

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: How to make a script toggle from pressing a key?

Post by Mandit_Gamer » 21 Aug 2021, 04:37

Wats the default toggle shortcut?

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: How to make a script toggle from pressing a key?

Post by Mandit_Gamer » 21 Aug 2021, 04:38

braunbaer wrote:
21 Aug 2021, 04:30
What do you mean with "toggle the script"?

If you want to toggle a specific hotkey, for example f1, you can write

Code: Select all

f1Active:=true

#if f1Active
f1::  Msgbox F1 was pressed
#if
Now you can use say f2 to toggle f1:

Code: Select all

f2:: f1Active:=not f1Active
Uhm can we talk on discord as this is a bit buggy, my discord name: ItzPikachuOfficial#0542

braunbaer
Posts: 483
Joined: 22 Feb 2016, 10:49

Re: How to make a script toggle from pressing a key?

Post by braunbaer » 21 Aug 2021, 12:18

Mandit_Gamer wrote:
21 Aug 2021, 04:38
this is a bit buggy,
What's buggy? I am not on Discord, sorry.

There is no default shortcut. In your script, you define the hotkeys you want to use.
Maybe you can try to explain what you want to achieve exactly.

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: How to make a script toggle from pressing a key?

Post by Mandit_Gamer » 21 Aug 2021, 23:49

Can you help me with something else? [Leave this topic], how to make a specific line/program in a script run for a specific time?

Post Reply

Return to “Ask for Help (v1)”