Help with toggle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Greg_Roberts
Posts: 2
Joined: 17 Mar 2024, 04:25

Help with toggle

Post by Greg_Roberts » 17 Mar 2024, 04:34

Hello all. I am new and to this (started just a few hours ago) and am having some issues in using the toggle command

Below is the command I want to be toggled with ^q. I want it to be turned off when I put the command so that I can type z again without turning off the script.

Code: Select all

z:: ;"z"

Send {LButton Down} ;Press left mouse button

Send {LButton Up} ;release Left Mouse button 

Return
I spent an hour but to no avail so I ask for help :angel:

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
[Mod action: Moved topic from AHK v2 help to v1 help since this is not v2 code. ]

User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Help with toggle

Post by boiler » 17 Mar 2024, 07:01

Add this:

Code: Select all

^q::Suspend

Greg_Roberts
Posts: 2
Joined: 17 Mar 2024, 04:25

Re: Help with toggle

Post by Greg_Roberts » 19 Mar 2024, 04:04

Putting that turns off the entire script when its activated?
What I want is a button that temporary disable that command. Like If I click ^q I cant click the ` to click fast, but if I click ^q again I can now click ` to fast again.

User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Help with toggle

Post by boiler » 19 Mar 2024, 04:26

You didn't say you had other stuff in the script. Here's how you would change this part of it. Put the first line at the top of your script, before any hotkeys.

Code: Select all

On := 1

#If On
z:: ;"z"
Send {LButton Down} ;Press left mouse button
Send {LButton Up} ;release Left Mouse button 
Return
#If

^q::On := !On

Post Reply

Return to “Ask for Help (v1)”