Results 1 to 11 of 11

Thread: for loop issues

  1. #1
    Join Date
    Dec 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default for loop issues

    Hi,
    I'm having issues with a for loop, here's the code:
    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:
    Code:
    begin
    tab(middenTab+i*tabLengte);
    tvs;
    , but the second part
    Code:
    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:/

  2. #2
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    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

  3. #3
    Join Date
    Dec 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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:
    Code:
    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:
    Code:
    const
    aantalTabs=16;
    middenTab=51;
    tabLengte=1130/aantalTabs;
    
    var
    e: Integer;

  4. #4
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    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

  5. #5
    Join Date
    Dec 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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:
    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:/

  6. #6
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

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

  7. #7
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

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

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  8. #8
    Join Date
    Dec 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    tab(just clicks on a tab in chrome specified by the x coordinate):
    Code:
    procedure tab(x: Integer);
    begin
    wait(100);
    ClickMouse(x, 20, true);
    wait(100);
    end;
    home(just does alt+home)
    Code:
    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.

  9. #9
    Join Date
    Dec 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    You do realize you are using i* something instead of e* something, when your looping variable is the 'e' ?

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

  10. #10
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    //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.

    SCAR Code:
    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;

  11. #11
    Join Date
    Dec 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by caused View Post
    //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.

    SCAR Code:
    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 thanks RM!). But yes, yours is simpler, I might integrate that

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •