0

I want to achieve this

  1. press "a" > output "a"
  2. press "a" again > output "b"
  3. press "a" again > output "a"
  4. press "a" again > output "b"
  5. keep repeating these...

Below script does what I want, but with little issue. When I press and hold "a", it output "abababab"...... But I need it to act like keep outputing the current character until I release the key and activate the toggling.

i.e. press and hold "a" > output "aaaaaaaa"... > release "a" > stop outputing and toggle to "b"

Anyone know how can I achieve that? Thanks in advance!

Toggle:=0
$a::
Toggle:=!Toggle
if(Toggle=1) {
    send, a
} else {
    send, b
}
return
  • 1
    I'm not an AHK expert but there has to be a feature in it to detect when a key is pressed and then released. Try searching their help for those terms, or "key down" and "key up". – Twisty Impersonator Oct 5 at 16:46
0

This script should do the task. Note that when in the mode of replacing a by b (meaning the second a), a repeating press on a will repeat the b.

toggle:=0
apressed:=0
a::
    apressed:=1
    if (toggle=0) {
        send, a
    } else {
        send, b
    }
    return

a up::
    apressed:=0
    toggle:=!toggle
    return

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.