SRL Archive - OSR Help

for loop issues


Terror Factor

2010-02-25 14:29:15

Hi,
I'm having issues with a for loop, here's the code:
procedure submittvs;
begin

for e:= 0 to 4 do //tab1 tà 5
begin
tab(middenTab+i*tabLengte);
tvs;
tab(middenTab+(i+aantalTabs-5)*tabLengte);
home;
writeln('tab '+IntToStr(e+1));
end;

//for e:= 5 to aantalTabs-1 do //tab6 to x
//begin
//tab(middenTab+i*tabLengte);
//tvs;
//tab(middenTab+(i-5)*tabLengte);
//home;
//writeln('tab '+IntToStr(e+1));
//end;

end;
The goal of the code is to go tab one(in chrome), submit something, go to the 5th last tab, refresh it. Afterwards it should go to tab 2, submit, go to the 5th last tab, refresh, etc.

aantalTabs is the number of tabs I want to use. middenTab is the middle x coordinate of the first tab. tabLengte is the total length of all the tabs, divided by the number of tabs.

The function should work, in another procedure it initializes all the tabs(tab1, refresh, tab2, refresh, tab3, refresh, ..), and that works without any problem.

However, with this code, it errors with tab 5(or e=4). This part works:
begin
tab(middenTab+i*tabLengte);
tvs;
, but the second part
tab(middenTab+(i+aantalTabs-5)*tabLengte);
home;
writeln('tab '+IntToStr(e+1));
end;
doesn't. Instead of clicking the last tab, it clicks on the plus-button in chrome. Technically that shouldn't even be possible(the coordinates NEVER get to there:/).

Another issue that I've noticed, while I tried to fix the script:
I've commented the second part of the procedure(5 to x), and tried to make the first part into this: "e:=4 to 4 do". That doesn't work, it ALWAYS starts at zero, even when I tried "e:=3 to 4 do". I have no idea why:/

caused

2010-02-25 14:39:21

Hmmn, how do you search for tabs ?.

The more tabs you're having open the smaller they become. So, you'd need to search for the first, second,third….. "x" or so. And not just going x pixels to the right.

~caused

Terror Factor

2010-02-25 14:52:04

I don't search for tabs, I enter the coords for the first tab manually.
(the coords work, this is the "refresh" procedure, that works flawless:
procedure reloadTabs;
begin
for e:=0 to aantalTabs-1 do
begin
tab(middenTab+e*tabLengte);
home;
end;
end;
)

This is the part with the const and vars:
const
aantalTabs=16;
middenTab=51;
tabLengte=1130/aantalTabs;

var
e: Integer;

caused

2010-02-25 15:02:20

I'd suggest not clicking tabs anyways.
Rather use shortcuts like "control+tab" to switch through tabs.

And ctrl+w to close tabs, ctrl+r to reload and so on.

~caused

Terror Factor

2010-02-25 15:12:47

I use the home button(well, the shortcut: alt+home) to refresh. I could try the ctrl+tab to go through the tabs, I'll give it a go. But anyway: I want to know what causes those 2 errors, it is so weird :/

Btw, you can see I've used the writeln function for debuggingpurposes. that does work.
So if I use this code:
for e:= 4 to 4 do                       //tab1 tà 5
begin
tab(middenTab+i*tabLengte);
tvs;
tab(middenTab+(i+aantalTabs-5)*tabLengte);
home;
writeln('tab '+IntToStr(e+1));
end;
It puts out "tab 5" all the time, but the script starts clicking on the first tab:/

caused

2010-02-25 15:18:02

Well, what does your tab, tvs and home functions do ?.

Sir R. M8gic1an

2010-02-25 15:27:38

You do realize you are using i* something instead of e* something, when your looping variable is the 'e' ?

~RM

Terror Factor

2010-02-25 15:30:08

tab(just clicks on a tab in chrome specified by the x coordinate):
procedure tab(x: Integer);
begin
wait(100);
ClickMouse(x, 20, true);
wait(100);
end;
home(just does alt+home)
procedure home;
begin
wait(200);
KeyDown(18);
wait(20);
KeyDown(36);
wait(50);
KeyUp(36);
wait(20);
KeyUp(18);
wait(100);
end;

and tvs fills in some stuff on the page.

Terror Factor

2010-02-25 15:31:25

From: Rasta Magician
You do realize you are using i* something instead of e* something, when your looping variable is the 'e' ?

~RM


OMFG:duh:
How stupid am I -_-
Thanks, I'll run it and see if it works!

caused

2010-02-25 15:31:27

//EDIT.Oh nvm :].. The most obvious errors can really be the toughest sometimes … ;)

Yeah i did notice that too.

Here's a function that cliks a given Tab in Chrome. If its standard sized it would even hit the button, but i'd really suggest not using that way of changing tabs.


const
aantalTabs=18;
middenTab=198;
//*Clicks a tab in Google Chrome*//
procedure clicktab(tab:integer);
begin
ClickMouse(109+middentab*tab,aantalTabs,true);
end;

//Click6 tabs
for e:= 0 to 5 do
begin
ClickTab(e);
wait(1000);
end;

Terror Factor

2010-02-25 15:42:52

From: caused
//EDIT.Oh nvm :].. The most obvious errors can really be the toughest sometimes … ;)

Yeah i did notice that too.

Here's a function that cliks a given Tab in Chrome. If its standard sized it would even hit the button, but i'd really suggest not using that way of changing tabs.


const
aantalTabs=18;
middenTab=198;
//*Clicks a tab in Google Chrome*//
procedure clicktab(tab:integer);
begin
ClickMouse(109+middentab*tab,aantalTabs,true);
end;

//Click6 tabs
for e:= 0 to 5 do
begin
ClickTab(e);
wait(1000);
end;
my function for clicking tabs works(well, now it does:p thanks RM!). But yes, yours is simpler, I might integrate that:p