i've got a problem regarding javascript and loops.
I've got a macro1 which clicks on a start button which exists x times. When it clicks on this button, a new tab is opened
Then i got another macro2 which clicks on another button on the new tab, then close the tab.
Then the start button which was clicked disappears, and the macro1 clicks the next one, until there is no button any longer.
The problem is, that there is not always a second button on the new opened page in tab2.
So if there is no Button in tab2, it should close the Tab directly and start macro1 again, searching for a new button in tab1.
I've made a while loop for clicking all the buttons in tab1, and when it doesnt find a button anymore it breaks the loop and move on with another macro.
I've tried to check in macro2 if the Button is on the second tab with IMAGESEARCH, and if it cant find that button it should close the tab, break the loop and move to macro1 again. Macro1 clicks the start Button again, then Macro2 plays and it checks again if there is this Button on the page. If yes, then click it, if not close tab and move to macro1 again.
Code: Select all
while(true)
{
var ret=iimPlay(start);
while(true)
{
var ret2=iimPlay(check);
if(ret2<0)
{
iimPlay("C:\\Users\\Karsten\\Documents\\iMacros\\Macros\\New_System\\tab_close");
}
{
break;
}
}
if(ret<0)
{
break;
}
}
Edit: Ok problem solved by myself. This code works fine:
Code: Select all
while(true)
{
var ret=iimPlay(start);
if (ret>0)
{
var ret2=iimPlay(checklike);
if (ret2<0)
{
iimPlay("C:\\Users\\Karsten\\Documents\\iMacros\\Macros\\New_System\\tab_close");
}
}
else
{
break;
}
}