How to toggle one key with 2 functions Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Jeemeli

How to toggle one key with 2 functions

24 May 2018, 04:14

Hi, Im new to all of this so can someone tell me how to make a script where if I press a key (x) it does what key x is supposed to do but also switches key x's function into key y. Then when I press the same key, it does what key y is supposed to do and then switches it back to key x. SO basically I want one button to toggle between 2 functions, every other time I press it, it registers as function x and every other time as function y. Is this possible and if it is how do I do it?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to toggle one key with 2 functions  Topic is solved

24 May 2018, 05:03

Code: Select all

1::(toggle := !toggle) ? funcX() : funcY()
Jeemeli

Re: How to toggle one key with 2 functions

24 May 2018, 05:14

swagfag wrote:

Code: Select all

1::(toggle := !toggle) ? funcX() : funcY()
So where do I put the buttons to in the code if I want to toggle the key for letter x between functions x and 3
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to toggle one key with 2 functions

24 May 2018, 10:25

Code: Select all

1::(toggle := !toggle) ? funcX() : funcY()

funcX() {
	MsgBox % "Hello from X" 
}

funcY() {
	MsgBox % "Hello from Y" 
}
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to toggle one key with 2 functions

25 May 2018, 07:47

Hallo,
or do you want a Switching Remapping?

Code: Select all

*x::Send % !Y ? "{Blind}{x DownR}" : "{Blind}{y DownR}"
*x Up::Send % (Y := !Y) ? "{Blind}{x Up}" : "{Blind}{y Up}"

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 27 guests