Press "F10" to hold CTRL key, press "F10" again to release

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dhopkins802
Posts: 8
Joined: 04 Apr 2021, 23:30

Press "F10" to hold CTRL key, press "F10" again to release

14 Apr 2021, 22:49

Hi all, subject pretty much says it all. I'm stumbling through other scripts people have written that do similar actions, but others seem to want to trigger a CTRL holder with one key, and then cancel it with another. Is it possible to press a hotkey "F10" to trigger a hold of the CTRL key, then press F10 again to release it?

I've started with this, but I think i'm way off -

Code: Select all

#MaxThreadsPerHotkey, 2
Toggle := 0

F10::
Toggle := !Toggle
If (Toggle){
   {Ctrl Down}
} else {
   {Ctrl Up}
}

Return
[Mod edit: [code][/code] tags added.]


Thank you!
Rohwedder
Posts: 7644
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Press "F10" to hold CTRL key, press "F10" again to release

15 Apr 2021, 03:33

Hallo,
try:

Code: Select all

F10::Send, {Ctrl Down}
*F10::Send, {Ctrl Up}
1. without Send it could never work.
2. when control is down the hotkey F10:: cannot trigger.
dhopkins802
Posts: 8
Joined: 04 Apr 2021, 23:30

Re: Press "F10" to hold CTRL key, press "F10" again to release

15 Apr 2021, 08:12

Rohwedder wrote:
15 Apr 2021, 03:33
Hallo,
try:

Code: Select all

F10::Send, {Ctrl Down}
*F10::Send, {Ctrl Up}
1. without Send it could never work.
2. when control is down the hotkey F10:: cannot trigger.
That worked, thank you!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, jaka1, RussF and 312 guests