Loop / Cleaner code

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iHuggles
Posts: 6
Joined: 14 Nov 2017, 14:44

Loop / Cleaner code

14 Nov 2017, 14:56

Originally I was doing this and it was just really messy and I did not like the look at it.

Code: Select all

Numpad5::
{
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400

Send {A Down}
Sleep, 800
Send {A up}
sleep, 400
Send {A Down}
Sleep, 800
Send {A up}
sleep, 400
Send {A Down}
Sleep, 800
Send {A up}
sleep, 400
Send {A Down}
Sleep, 800
Send {A up}
sleep, 400
Send {A Down}
Sleep, 800
Send {A up}
sleep, 400


}


Return
Then I tried doing this

Code: Select all

Numpad5::
{
Send {D Down}
Sleep, 800
Send {D up}
sleep, 400
loop, 10
block

Send {A Down}
Sleep, 800
Send {A up}
sleep, 400
loop, 10
block

}


Return
Im not a huge coder and I have read the Loop page. I just dont understand how to make a command like D Down and D up repeat a couple times without spamming the same command over and over again and then continue onto another set of commands I have told it to do like A down > A Up. Any help would be amazing! I have been messing around with it for a couple hours just cant seem to get it.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Loop / Cleaner code

14 Nov 2017, 15:00

Code: Select all

Numpad5::
Loop 10
{
Send {d down} ; I think {D Down} would be Shift+d, so you can keep it capital if you want Shifts
Sleep 800
Send {d up}
Sleep 400
}
Loop 10
{
Send {a down}
Sleep 800
Send {a up}
Sleep 400
}
return
The block is the group of commands wrapped inside the braces { }. This is what signals to the command above that if it's a flow-control command like If or Loop that all of these commands are a part of it.

Edit, but in this case, you might be able to avoid the Sleep commands by using SetKeyDelay. Could save a few lines of code, but what I had above should work. It is untested though.
iHuggles
Posts: 6
Joined: 14 Nov 2017, 14:44

Re: Loop / Cleaner code

14 Nov 2017, 15:04

Awesome! Its working great! The Capital D would explain why it would shift. Thanks so much!
iHuggles
Posts: 6
Joined: 14 Nov 2017, 14:44

Re: Loop / Cleaner code

14 Nov 2017, 15:05

Awesome! Its working great! The Capital D would explain why it would shift. Thanks so much!
iHuggles
Posts: 6
Joined: 14 Nov 2017, 14:44

Re: Loop / Cleaner code

14 Nov 2017, 15:05

Awesome! Its working great! The Capital D would explain why it would shift. Thanks so much!
iHuggles
Posts: 6
Joined: 14 Nov 2017, 14:44

Re: Loop / Cleaner code

14 Nov 2017, 15:05

Awesome! Its working great! The Capital D would explain why it would shift. Thanks so much!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 256 guests