## Left and right click key auto cycle

Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Left and right click key auto cycle

hey guys im trying to figure out how to have left click cycle 1 2 3keys with a break and continue if i click and let go. samething for left click with 4 5 6 any help would be much appreciated.
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

### Re: Left and right click key auto cycle

Try to describe your idea clearly before asking. You didn't even include an example
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

left click of mouse cycles in loop of keys 1 2 3

right click of mouse cycles in loop of keys 4 5 6

if let go of click it stops, hold click it continues.
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

forgive me if i dont seem to make sense just got back from a 26 hour drive none stop

cy·cle
/ˈsīk(ə)l/Submit
noun
plural noun: cycles
1.
a series of events that are regularly repeated in the same order.

yeah im sure thats what i put down, cycles =)
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

### Re: Left and right click key auto cycle

It i still very complicated... Cycles in loop is basically as saying loops in a loop and it makes no sense.
If you could write down exact steps you need to accomplish I might be able to help you

Example of a script:
1.I press the number 1 key.
2.AHK sends left button down repeatedly in specific intervals.
3.I unpress the number 1 key.
4.AHK stops sending left button repeatedly.
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

yeah not sure if I can.

Left mouse click = loop of keys 1 2 3

Right mouse click = loop of keys 4 5 6

while in loop if stopped, holds then continues when clicking again.

meaning if I hold the loop and stop at 2 in the loop when i reclick it will continue from 2 in the loop.

not sure how else i can explain =(
Masonjar13
Posts: 1488
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

### Re: Left and right click key auto cycle

It's explained quite clearly. You just need to have a loop that checks if the particular key is still being held, along with a hotkey.

Code: Select all

``````\$LButton::
while(getKeyState("LButton","P"))
send 123
return
\$RButton::
while(getKeyState("RButton","P"))
send 456
return
``````
As it's written here, it won't work if both are held at the same time. That can be changed though, if you want it to work like that.
OS: Windows 7 Ultimate | Editor: Notepad++
My Personal Function Library | Check Out My Computer Rig
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

### Re: Left and right click key auto cycle

It is not clear at all @Masonjar13, what you wrote will not work 9 times out of 10 because you have no context (it will only work in notepad for testing and if lucky, in web browser game chat?). For example OP said he needs to memorize last button and continue the loop from the button it last stopped. This means he most likely needs a physical button press simulation, with delays, maybe to use in a game? What if it's not a chat window? Your script will not register at all in that case.

At OP: while you hold left button the program must send 1, wait, send 2, wait, send 3, wait, send 1, etc... ? and when you release the button it stops but the next time you hold left button it continues from the number it stopped at previously?
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

### Re: Left and right click key auto cycle

Here's a test script to see if it does what you want. Press "A" to try:
Spoiler
Masonjar13
Posts: 1488
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

### Re: Left and right click key auto cycle

.. I'll just blatantly ignore your response, seeing as it makes no sense and that code is.. pretty bad. Though, yes, I did miss where OP asked to keep the cycle when stopped. Easy fix.

Code: Select all

``````setKeyDelay,25,25 ; good starting point for games
arr1:=[1,2,3]
arr2:=[4,5,6]
arr1L:=arr2L:=1

\$^F1::t:=!t

#if t
\$LButton::
while(getKeyState("LButton","P") && t){
send % arr1[arr1L]
arr1L:=++arr1L>arr1.maxIndex()?1:arr1L
}
return
\$RButton::
while(getKeyState("RButton","P") && t){
send % arr2[arr2L]
arr2L:=++arr2L>arr2.maxIndex()?1:arr2L
}
return
``````
I also added a toggle so it won't effectively disable the mouse buttons (Ctrl+F1).
OS: Windows 7 Ultimate | Editor: Notepad++
My Personal Function Library | Check Out My Computer Rig
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

### Re: Left and right click key auto cycle

You didn't ignore my response and just made a fool out of yourself once again

Also did you even test your "pretty good" code? It is nowhere near applicable. But you got to love that "good starting point for games" comment. Maybe after a year of trial and error learning from that starting point you might produce something which actually works?
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

### Re: Left and right click key auto cycle

mast4rwang wrote:
12 Jan 2019, 18:18
Here's a test script to see if it does what you want. Press "A" to try:
Spoiler

This code will never expire because it simulates physical button press. You can test it and edit as you like
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

Mason thank you for ur post, going to check to see if it works
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

Mason this works awesome, the timer is to fast and left click was doing everything. right now I tweaked the code a bit and for some reason right click does 2 4 5 6 but when i try it on a note pad it does 456, not sure whats going on there but i can work it with all i really need is to slow down the cycle about 1.5 secs
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

ok so 2 and 6 are linked trying to see why
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

ok it works, i just dont get somethings on whats going on. when i try in on a note pad it work perfectly, when in game it goes 123 sometimes 1 and 3 for left click, for right click goes 4 5 6 and 2 and 6.
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

### Re: Left and right click key auto cycle

Mason there are some stuff that are not working right like what mast said but in all honesty mason ur code works fine thank you so much
Masonjar13
Posts: 1488
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

### Re: Left and right click key auto cycle

Minrah wrote:
22 Jan 2019, 12:30
Mason there are some stuff that are not working right like what mast said but in all honesty mason ur code works fine thank you so much
Apologies for not getting back to you sooner, I've been very busy!

You can slow it down with a sleep inside the loops. As for why it's skipping some, probably because it's too fast. You can also try setting the key delay to 50,50, or higher, as necessary.

Code: Select all

``````setKeyDelay,50,50
arr1:=[1,2,3]
arr2:=[4,5,6]
arr1L:=arr2L:=1

\$^F1::t:=!t

#if t
\$LButton::
while(getKeyState("LButton","P") && t){
send % arr1[arr1L]
arr1L:=++arr1L>arr1.maxIndex()?1:arr1L
sleep 50
}
return
\$RButton::
while(getKeyState("RButton","P") && t){
send % arr2[arr2L]
arr2L:=++arr2L>arr2.maxIndex()?1:arr2L
sleep 50
}
return``````
OS: Windows 7 Ultimate | Editor: Notepad++
My Personal Function Library | Check Out My Computer Rig

### Who is online

Users browsing this forum: Slafe17, Xtra and 49 guests