H S
H S

Reputation: 15

How to press and hold 3 keys one after the other

New to Auto Hotkey. I’m looking to create a hotkey to press and hold Control, then press and hold Alt, then press “W”, then let go of all 3 and do the same after 30 seconds.

I tried this but unsure if it’s right. Thanks!

#SingleInstance, force
#MaxThreadsPerHotkey 2
F10::   
    Toggle := !Toggle
    while Toggle
    {
        Send, {Ctrl}
        Send, {Alt}
        Send, {W}
        Sleep, 30000 ;
    }
Return

Upvotes: 0

Views: 451

Answers (1)

Spyre
Spyre

Reputation: 2344

This should work:

#SingleInstance, force
F10::   
    Toggle := !Toggle
    if (Toggle)
    {
        gosub, sub
        SetTimer sub, 30000
    }
    else{
        SetTimer sub, Off
    }
Return

sub:
    Send ^!w
return

Notes:

  1. When a sleep command is used, the program is unable to detect hotkeys being pressed. Instead of using multiple threads, it would be better to implement a SetTimer/ Subroutine system.
  2. In order to send Ctrl+Alt+W, just use Send ^!w. (^ means Control, ! means Alt, and and w means w; for more info, see modifiers.

Upvotes: 1

Related Questions