Left and right click key auto cycle

Ask gaming related questions
Minrah
Posts: 9
Joined: 09 Jan 2019, 12:50

Left and right click key auto cycle

09 Jan 2019, 12:54

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

09 Jan 2019, 16:32

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

10 Jan 2019, 12:05

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

11 Jan 2019, 11:59

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

11 Jan 2019, 12:52

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 :D

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

11 Jan 2019, 15:45

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 =(
User avatar
Masonjar13
Posts: 1463
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Left and right click key auto cycle

12 Jan 2019, 17:45

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

12 Jan 2019, 17:58

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

12 Jan 2019, 18:18

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

Re: Left and right click key auto cycle

14 Jan 2019, 03:46

.. 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

14 Jan 2019, 05:34

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

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? :bravo:
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

Re: Left and right click key auto cycle

16 Jan 2019, 15:47

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

21 Jan 2019, 23:38

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

22 Jan 2019, 00:03

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

22 Jan 2019, 00:04

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

22 Jan 2019, 00:17

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

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
User avatar
Masonjar13
Posts: 1463
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Left and right click key auto cycle

26 Jan 2019, 12:12

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

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 29 guests