Cycling forwards and backwards through a list. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
graypersona
Posts: 6
Joined: 17 Jul 2016, 04:30

Cycling forwards and backwards through a list.

27 May 2017, 13:22

Hello. I have this script that cycles through a list of buttons with a single key.
I would it to cycle through the list but with two buttons-one for selecting the next value in the list
and one for selecting the previous value(kind of like flipping through a book)
this is my current script:

Code: Select all

#IfWinActive, ahk_exe Photoshop.exe





list1 := ["{f8}", "+{f8}"]
 
list2 := ["{f9}", "+{f9}"]

list3 := ["{f7}", "+{f7}"]

list4 := ["{f11}","+{f11}"]

list5 := ["{f12}", "+{f12}"]


 
$1::Cycle(list1)
 
$2::Cycle(list2)

$3::Cycle(list3)

$4::Cycle(list4)

$5::Cycle(list5)


 
Cycle(list){
	Global
	Counter%A_ThisHotkey% := Counter%A_ThisHotkey% = "" ? 0 : Counter%A_ThisHotkey%
	Send, % list[(Counter%A_ThisHotkey% < list.Length() ? ++Counter%A_ThisHotkey% : Counter%A_ThisHotkey% := 1)]
}




any help would be appreciated.
Xeno234
Posts: 71
Joined: 24 Mar 2017, 18:14

Re: Cycling forwards and backwards through a list.  Topic is solved

27 May 2017, 19:00

Code: Select all

list1 := ["1", "a", "b", "c", "d", "e"] 
list2 := ["1", "a", "b", "c", "d", "e"] 
$1::Cycle(list1)
$2::Cycle(list1, 1)
$3::Cycle(list2)
$4::Cycle(list2, 1)
 
Cycle(list, back = 0){
	list[1] := list[1] + (back ? -1 : 1)
	list[1] := list[1] = 1 ? list.length() : list[1] = list.length() + 1 ? 2 : list[1]
	Send, % list[list[1]]
}
graypersona
Posts: 6
Joined: 17 Jul 2016, 04:30

Re: Cycling forwards and backwards through a list.

28 May 2017, 00:25

Xeno234 wrote:

Code: Select all

list1 := ["1", "a", "b", "c", "d", "e"] 
list2 := ["1", "a", "b", "c", "d", "e"] 
$1::Cycle(list1)
$2::Cycle(list1, 1)
$3::Cycle(list2)
$4::Cycle(list2, 1)
 
Cycle(list, back = 0){
	list[1] := list[1] + (back ? -1 : 1)
	list[1] := list[1] = 1 ? list.length() : list[1] = list.length() + 1 ? 2 : list[1]
	Send, % list[list[1]]
}

Thank you really appreciate it!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Frogrammer, Google [Bot] and 154 guests