each click sends key

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
eros1002
Posts: 1
Joined: 29 Mar 2023, 13:37

each click sends key

Post by eros1002 » 29 Mar 2023, 13:44

can someone help me with code i need. i want to every click i do is it will send a key. for example, first rightclick after the click it will send letter a, then next click will letter b, 3rd click will send letter C.
Last edited by gregster on 29 Mar 2023, 13:49, edited 1 time in total.
Reason: Post was split from completely unrelated topic. Another duplicate post - also in an unrelated topic - was disapproved.

Hobby77
Posts: 30
Joined: 25 Jan 2021, 01:27

Re: each click sends key

Post by Hobby77 » 29 Mar 2023, 20:11

Maybe you need an int value variable, add 1 every time you click, and clear it for the third time.

User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: each click sends key

Post by mikeyww » 29 Mar 2023, 20:50

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v2.0
~RButton Up:: {
 Static n := 0
 Send SubStr('abc', ++n := Mod(0 n, 3), 1)
}

Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: each click sends key

Post by Rohwedder » 30 Mar 2023, 00:32

@mikeyww,
the leading zero in Mod(0 n, 3) was my AutoHotkey v1 method to read an uninitialized variable as zero.
AutoHotkey v2 (unfortunately) forbids uninitialized variables. Only Mod(n, 3)!

User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: each click sends key

Post by mikeyww » 30 Mar 2023, 06:56

Good point! Thank you, Rohwedder.

Post Reply

Return to “Ask for Help (v2)”