We must loop using while(), and set a condition for it to stop. I have tried this CUI script and it works at mine. But you've got to modify it to suit your need (as every CUI script is device-dependant)
EDIT : I have fixed the script, just download the flow in the following post
Code: Select all
sleep(500);
list = newList();
scroll = 0;
id = "android:id/title";
while(scroll < 100) //set a max scroll so no infinite loop
{
index = 0; temp = newList();
//loop over the whole index on screen, usually it is 8-15 item per screen
while(getTextByIdAndIndex(id, index) != null)
{
addElement(temp, getTextByIdAndIndex(id, index));
index = index + 1;
}
//if no element found, id must be wrong, stop immediately
if(isEmpty(temp))
break;
//find the next element in previous element index, in reverse
dup = indexOfElement(reverse(copyList(list)), temp[0]);
end = length(temp) - 1; //save the length first, before removing elements
removeElements(temp, 0, dup+1);
if(dup >= 2)
scroll = 100; //stop until this iteration if it reach end of scroll
addAllElements(list, temp);
//add the action to iterate here
for(i in [dup+1 to end])
{
clickByIdAndIndex(id, i);
sleep(100);
clickById("android:id/switch_widget");
sleep(100);
back();
sleep(100);
}
scrollForwardById(id);
scroll = scroll + 1;
sleep(200); //don't set this too low, otherwise the script don't have enough time to capture the text
}
The action to iterate can be put at the /* */ part. I just use clickByIdAndIndex() there, assuming you want to click on each of them.
You probably should understand the flow of the script first, before adding your own action
temp contain the next scroll list to iterated.
dup is to find whether the next
temp has the same element in the previous saved
list. If there is, remove that, as we have iterated over it in previous scroll.
Hence, in each iteration, we only use the dup+1 (the index which haven't be iterated yet) until the length of temp - 1.
PS : This only work in Automagic 1.36 above (currently dev version)