Help a noob! Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
WMD_Wrists
Posts: 3
Joined: 21 May 2020, 10:18

Help a noob!

21 May 2020, 10:30

Hi all!
Noob here and I am sorry if the answer to my question is somewhere in the forum but it's hard to find when I don't even know the keywords to describe what I want to do.

So I want to make a macro that when I use it one will send a sequence of commands that will be the same every time and a command that will be one of two alternatives.
For example when I press "1" once it will send: 1,2,3,x and when I press "1" a second time it will send: 1,2,3,y and then 3rd time 1,2,3,x and so on.
Is this possible?

Thanks!
User avatar
Chunjee
Posts: 524
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Help a noob!

21 May 2020, 10:36

Yes it is possible. You will need a counter at the global scope to increment each time the hotkey is pressed and what to do inside the hotkey for each increment. Don't forget you will need to reset it back to 1 at the end of the last option.
User avatar
Yakshongas
Posts: 483
Joined: 21 Jan 2020, 08:41
Facebook: Yakshongas

Re: Help a noob!

21 May 2020, 11:02

Something like this:

Code: Select all

Num := True

$1::
    Num :=!Num
    If (Num = False)
    {
        SendInput, 1,2,3,x
    }
    Else if (Num = True)
    {
        SendInput, 1,2,3,y
    }
Return
Or:

Code: Select all

Num = 0

$1::
    Num++
    If (Num = 1)
    {
        SendInput, 1,2,3,x
    }
    Else if (Num >= 2)
    {
        SendInput, 1,2,3,y
        Num = 0
    }
Return
Please mark your topics as solved if you don't need any further help. ✅
WMD_Wrists
Posts: 3
Joined: 21 May 2020, 10:18

Re: Help a noob!  Topic is solved

21 May 2020, 12:42

Yakshongas wrote:
21 May 2020, 11:02
Something like this:

Code: Select all

Num := True

$1::
    Num :=!Num
    If (Num = False)
    {
        SendInput, 1,2,3,x
    }
    Else if (Num = True)
    {
        SendInput, 1,2,3,y
    }
Return
Or:

Code: Select all

Num = 0

$1::
    Num++
    If (Num = 1)
    {
        SendInput, 1,2,3,x
    }
    Else if (Num >= 2)
    {
        SendInput, 1,2,3,y
        Num = 0
    }
Return
Thanks a lot! Unfortunately this doesen work. It sends the first sequence, second hit of the button does nothing and then it sends the first sequence again.
WMD_Wrists
Posts: 3
Joined: 21 May 2020, 10:18

Re: Help a noob!

21 May 2020, 12:46

Oh just saw the second one and it works like a charm! Thanks!

[Mod edit: selected 'completed' option on your behalf] :thumbup:
User avatar
flyingDman
Posts: 758
Joined: 29 Sep 2013, 19:01

Re: Help a noob!

21 May 2020, 13:05

Simplify:

Code: Select all

$1::sendinput % (x := !x) ? "1,2,3,x" : "1,2,3,y"

Return to “Ask For Help”

Who is online

Users browsing this forum: Robbl, Rohwedder and 42 guests