switching keys Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
qwerty2002
Posts: 7
Joined: 07 Jan 2018, 17:47

switching keys

07 Jan 2018, 17:58

Toggle := 1


F::Send, % Toggle = 1 ? ( "3", Toggle := 0 ) : ( "4", Toggle := 1 )

how do i add a keywait to this

also is it possible to make it work while holding down shift key?, it seems to stop working while holding down shift.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: switching keys

07 Jan 2018, 22:59

Change F:: to *f::, which will allow any modifier key to be held down while the f key is pressed. If you want only specifically shift to be allowed, that can be accomplished like this:

Code: Select all

f::
+f::
Send, % Toggle = 1 ? ( "3", Toggle := 0 ) : ( "4", Toggle := 1 )
return
What do you mean by add a keywait to this? What are you trying to accomplish? You don't want the send to take place until the f key is released? You can add up to the hotkey name to have it wait until it is released: f up::
qwerty2002
Posts: 7
Joined: 07 Jan 2018, 17:47

Re: switching keys

08 Jan 2018, 08:56

boiler wrote:Change F:: to *f::, which will allow any modifier key to be held down while the f key is pressed. If you want only specifically shift to be allowed, that can be accomplished like this:

Code: Select all

f::
+f::
Send, % Toggle = 1 ? ( "3", Toggle := 0 ) : ( "4", Toggle := 1 )
return
What do you mean by add a keywait to this? What are you trying to accomplish? You don't want the send to take place until the f key is released? You can add up to the hotkey name to have it wait until it is released: f up::

that worked a treat, i want a keywait so when i hold down F it doesn't switch between the two numbers, infinitely.

i'd rather have to press F each time for it to switch, if i have my finger held down on the F key i don't want to rotate between 3-4 until my finger has lifted off the F key
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: switching keys  Topic is solved

08 Jan 2018, 09:02

So you changed each to f up:: and +f up:: and it's doing what you want now, right?
qwerty2002
Posts: 7
Joined: 07 Jan 2018, 17:47

Re: switching keys

08 Jan 2018, 16:05

boiler wrote:So you changed each to f up:: and +f up:: and it's doing what you want now, right?
perfect!.
qwerty2002
Posts: 7
Joined: 07 Jan 2018, 17:47

Re: switching keys

20 Feb 2018, 15:54

boiler wrote:So you changed each to f up:: and +f up:: and it's doing what you want now, right?
is it possible to do 2-3-4, instead of just two
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: switching keys

20 Feb 2018, 16:18

Yes. You just need to nest the ternary if statement.

Code: Select all

Toggle := 1
f::
+f::
Send, % Toggle = 1 ? ( "2", Toggle := 2 ) : ( Toggle = 2 ? ( "3", Toggle := 3 ) : ( "4", Toggle := 1 ) )
return
qwerty2002
Posts: 7
Joined: 07 Jan 2018, 17:47

Re: switching keys

22 Feb 2018, 21:03

boiler wrote:Yes. You just need to nest the ternary if statement.

Code: Select all

Toggle := 1
f::
+f::
Send, % Toggle = 1 ? ( "2", Toggle := 2 ) : ( Toggle = 2 ? ( "3", Toggle := 3 ) : ( "4", Toggle := 1 ) )
return
that worked well,

*f up::
+f up::
Send, % Toggle = 1 ? ( "3", Toggle := 0 ) : ( "4", Toggle := 1 )
return

i wanna make this^ script reset back to (3) when i press any of the following keys (c) (v) (2) (1)

also whats your paypal address all the help you've given me i feel it's only right to chuck you at least $5-10

thanks - qwerty2002.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: switching keys

22 Feb 2018, 21:21

I assume you mean you press c, v, or 2, and it resets but doesn't send anything. It's just ready to send 3 again the next time you press f. You also don't need the second line in the script you showed (+f up::). That is already covered by putting the * on the first line (which also allows it to be a single-line hotkey definition).

Code: Select all

*f up::Send, % Toggle = 1 ? ( "3", Toggle := 0 ) : ( "4", Toggle := 1 )

c::
v::
2::
Toggle := 1
return
Thanks for the offer, but don't worry about it. Glad to help.
qwerty2002
Posts: 7
Joined: 07 Jan 2018, 17:47

Re: switching keys

26 Feb 2018, 13:15

boiler wrote:I assume you mean you press c, v, or 2, and it resets but doesn't send anything. It's just ready to send 3 again the next time you press f. You also don't need the second line in the script you showed (+f up::). That is already covered by putting the * on the first line (which also allows it to be a single-line hotkey definition).

Code: Select all

*f up::Send, % Toggle = 1 ? ( "3", Toggle := 0 ) : ( "4", Toggle := 1 )

c::
v::
2::
Toggle := 1
return
Thanks for the offer, but don't worry about it. Glad to help.
are you sure?, no i also want those keys active, but i simply want to reset it.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: switching keys

26 Feb 2018, 16:03

If you want c, v, and 2 to still do their normal function, then just put a ~ in front of them.
qwerty2002
Posts: 7
Joined: 07 Jan 2018, 17:47

Re: switching keys

09 Mar 2018, 10:52

boiler wrote:If you want c, v, and 2 to still do their normal function, then just put a ~ in front of them.
its really strange sometimes during the script running it will randomly start entering #4 after pressing the *2* *c* or *v*

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, ShatterCoder and 113 guests