Script for pressing the same key to activate and deactivate a keypress Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
markleunghatesyou
Posts: 4
Joined: 12 Apr 2022, 20:14

Script for pressing the same key to activate and deactivate a keypress

16 Apr 2022, 07:53

Hi, I'm trying to write a script that presses the S key down when I press backspace, and then releases the S key again when I press backspace agaim. Can someone please help me out?
aifritz
Posts: 301
Joined: 29 Jul 2018, 11:30
Location: Germany

Re: Script for pressing the same key to activate and deactivate a keypress

16 Apr 2022, 09:29

already answered here

https://www.autohotkey.com/board/topic/92188-break-a-loop-with-the-same-hotkey-its-pressed/

you can also do it with a while loop...

Code: Select all

#MaxThreadsPerHotkey 2
Backspace::
Toggle := !Toggle
while Toggle
  send s
return
markleunghatesyou
Posts: 4
Joined: 12 Apr 2022, 20:14

Re: Script for pressing the same key to activate and deactivate a keypress

16 Apr 2022, 22:57

Hi, it doesn’t work. It just sends a lot of S keys. I would like it to be a key down, and upon pressing backspace again, key up.
User avatar
boiler
Posts: 16986
Joined: 21 Dec 2014, 02:44

Re: Script for pressing the same key to activate and deactivate a keypress  Topic is solved

16 Apr 2022, 23:06

Code: Select all

Backspace::Send, % "{s " . ((Toggle := !Toggle) ? "down}" : "up}")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Playa 01 and 83 guests