A Hot Key where when i Press F1 it triggers F2 the first time and the second time triggers F3

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AutohotkeyAHK
Posts: 3
Joined: 14 Dec 2017, 03:58

A Hot Key where when i Press F1 it triggers F2 the first time and the second time triggers F3

14 Dec 2017, 10:55

Hello. I would like to make a keyboard shortcut which is very easy for someone that already knows AHK so if someone could help me so i dont have to get into this since its only one shortcut that i want. For the person that will help me i will give you a cookie. :cookie:

This is what i want to do:

I want to make a keyboard shortcut where whenever i press the F1 key on my keyboard it will trigger a keyboard shortcut that is assigned to F2 and then when i press F1 the second time it should trigger the keyboard shortcut that is assigned to F3.
F2 and F3 are assigned shortcuts in a software im working in. So whenever I'm working in that software, rather than pressing F2 and then F3 and then F2 and then F3 again etc. i want to be pressing F1 F1 F1 F1 etc.
Its very important to me that i will be pressing one button again and again rather than 2 buttons. How can i do this? Thank you in advance and I'm going to bake some cookies now.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: A Hot Key where when i Press F1 it triggers F2 the first time and the second time triggers F3

14 Dec 2017, 11:01

I think this is something you can accomplish on your own, so give it a whirl. If you can't get it, we can be more explicit in the answer.

Your hotkey is going to be F1.

See (Note: The first link is from the old forums, the second link is on these forums) http://www.autohotkey.com/board/topic/6 ... re-thread/ or https://autohotkey.com/boards/viewtopic.php?f=7&t=11952 for examples on how to go back and forth between doing one AHK command vs another. They use a custom variable as a toggle (on vs off; true vs false). This would be used with if/else. And each action would correspond with a different Send command. Note that for sending F2 and F3 keys, you'd use Send {F2} and Send {F3}. If you don't use the {}, then it would send a capital F and the number afterward.

The documentation has examples of how to use each command at the bottom of their pages, so refer to those if you're confused about how to use a command. Otherwise, feel free to ask any questions you need to.
AutohotkeyAHK
Posts: 3
Joined: 14 Dec 2017, 03:58

Re: A Hot Key where when i Press F1 it triggers F2 the first time and the second time triggers F3

14 Dec 2017, 11:59

Ok, i got it. I found a similar script somewhere else.

Thank you Exaskryz for motivating me to look more into it. I read the articles you linked. Here is 1 cookie for you :cookie: and two for me :cookie: :cookie:

Thank you

The script with different keys as the ones i mentioned:

Toggle := 1


G::Send, % Toggle = 1 ? ( "M", Toggle := 0 ) : ( "H", Toggle := 1 )

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Rohwedder, RussF and 308 guests