Xbutton2 switch rapidly between LButton Rbutton Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jmc92
Posts: 6
Joined: 31 Dec 2015, 01:35

Xbutton2 switch rapidly between LButton Rbutton

13 Jul 2018, 16:24

Any idea why it would just insert the text "RbuttonLbutton" into a text file, rather than actually doing the action?

Code: Select all

list=RButton,LButton    ; the list of keys and combos. comma 

separated. 
stringsplit, list, list,`,
Counter = 0

$Xbutton2::
    While GetKeyState("Xbutton2","P"){
        Counter := (Counter=list0) ? (1) : (Counter+1)
        Send % list%counter%
        Sleep 50
    }
return
Thank you to all who reply :)
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: Xbutton2 switch rapidly between LButton Rbutton  Topic is solved

13 Jul 2018, 17:55

Hello, this should work for your needs

Code: Select all

list:=["RButton","LButton"]    ; the list of keys and combos. comma 

Counter = 0

$XButton2::
    While GetKeyState("XButton2","P"){
        Counter := (Counter=List.MaxIndex()) ? (1) : (Counter+1)
		Key := List[counter]
        Send {%Key%}
		ToolTip, % List[counter]
        Sleep 50
    }
ToolTip
Return
You can leave the tooltip for testing, but stringsplit is outdated and you shouldn't use it. The array format is better and easier to work with once you understand how to grab data from it.
jmc92
Posts: 6
Joined: 31 Dec 2015, 01:35

Re: Xbutton2 switch rapidly between LButton Rbutton

13 Jul 2018, 18:34

MannyKSoSo wrote:Hello, this should work for your needs

Code: Select all

list:=["RButton","LButton"]    ; the list of keys and combos. comma 

Counter = 0

$XButton2::
    While GetKeyState("XButton2","P"){
        Counter := (Counter=List.MaxIndex()) ? (1) : (Counter+1)
		Key := List[counter]
        Send {%Key%}
		ToolTip, % List[counter]
        Sleep 50
    }
ToolTip
Return
You can leave the tooltip for testing, but stringsplit is outdated and you shouldn't use it. The array format is better and easier to work with once you understand how to grab data from it.
This does indeed seem to be the answer! :D Is their a way of making it faster/fastest possible?
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: Xbutton2 switch rapidly between LButton Rbutton

13 Jul 2018, 18:38

There are two ways you can do this. The first is to remove the Sleep and at the top add SetBatchLines -1 so the script runs as fast as possible.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 296 guests