; an example of an listbox which you can endlessly scroll, after ; it reaches the last item in the listbox it jumps back the ; first and vice versa ; GUITitle=Endless Listbox Loop, 25 ; create test list { ListBoxItems.= A_Index "|" } StringTrimRight, ListBoxItems, ListBoxItems, 1 ; trim trailing | Gui, Add, ListBox, x5 y5 w100 h200,%ListBoxItems% Gui, Show,, %GUITitle% Return #IfWinActive, Endless Listbox Up:: SendMessage, 0x188, 0, 0, ListBox1, %GUITitle% ; 0x188 is LB_GETCURSEL (for a ListBox). PreviousPos:=ErrorLevel+1 ControlSend, ListBox1, {Up}, %GUITitle% SendMessage, 0x18b, 0, 0, ListBox1, %GUITitle% ; 0x18b is LB_GETCOUNT (for a ListBox). ItemsInList:=ErrorLevel SendMessage, 0x188, 0, 0, ListBox1, %GUITitle% ; 0x188 is LB_GETCURSEL (for a ListBox). ChoicePos:=ErrorLevel+1 If (ChoicePos = PreviousPos) { SendMessage, 0x18b, 0, 0, ListBox1, %GUITitle% ; 0x18b is LB_GETCOUNT (for a ListBox). SendMessage, 390, (Errorlevel-1), 0, ListBox1, %GUITitle% ; LB_SETCURSEL = 390 } Return Down:: SendMessage, 0x188, 0, 0, ListBox1, %GUITitle% ; 0x188 is LB_GETCURSEL (for a ListBox). PreviousPos:=ErrorLevel+1 SendMessage, 0x18b, 0, 0, ListBox1, %GUITitle% ; 0x18b is LB_GETCOUNT (for a ListBox). ItemsInList:=ErrorLevel ControlSend, ListBox1, {Down}, %GUITitle% SendMessage, 0x188, 0, 0, ListBox1, %GUITitle% ; 0x188 is LB_GETCURSEL (for a ListBox). ChoicePos:=ErrorLevel+1 If (ChoicePos = PreviousPos) SendMessage, 390, 0, 0, ListBox1, %GUITitle% ; LB_SETCURSEL = 390 - position 'one' Return GuiEscape: ; ESC GuiClose: ; Program is closed ExitApp
Edit: See also
[Example] Endless scrolling in a listview
<!-- m -->http://www.autohotke...ic.php?p=272892<!-- m -->