0
votes

I have problems with an AutoHotKey script. When I press F1, the left mouse button is held but A is also pressed. Does anyone know how I can fix this?

#MaxThreadsPerHotkey, 2
Toggle := 0
Toggle2 := 0

F1::
Toggle := !Toggle
If (Toggle){
   Click, Down
} else {
   Click, Up
}

F2::
Toggle2 := !Toggle2
If (Toggle2){
   send {a down}
} else {
   send {a up}
}

1

1 Answers

0
votes

You need to tell autohotkey that you are done writing the code that should be executed when a hotkey is pressed by putting a Return after the last part you want to execute.

From the docs:

Returns from a subroutine to which execution had previously jumped via function-call, Gosub, Hotkey activation, GroupActivate, or other means.


So for your script:

#MaxThreadsPerHotkey, 2
Toggle := 0
Toggle2 := 0

F1::
Toggle := !Toggle
If (Toggle){
   Click, Down
} else {
   Click, Up
}
return

F2::
Toggle2 := !Toggle2
If (Toggle2){
   send {a down}
} else {
   send {a up}
}
return