Jump to content

Need help eliminating a repetitive task


wesley57
 Share

Recommended Posts

Hi, I have a script that runs internet explorer and uses the same URL with a slightly different address. For example:

Func PageSwitcher

$x = 0

If $x = 0 Then
 Run ("C:\Program Files\Internet Explorer\iexplore http://www.webpage.com/number1", "")
 $x = $x + 1
 Exitloop
Endif

If $x = 1 Then
 Run ("C:\Program Files\Internet Explorer\iexplore http://www.webpage.com/number2", "")
 $x = $x + 1
 Exitloop
EndIf

If $x = 2 Then
 Run ("C:\Program Files\Internet Explorer\iexplore http://www.webpage.com/number3", "")
 $x = $x - 2   ; now $x equals 0 and repeats the loop
 Exitloop
EndIf

EndFunc

Now, is there a more efficient way to do this? The way I have come up with works, but I have to have practically the same thing copied about 40 times with only a slight change in the link. I was thinking perhaps there was a way to take the "numberX" part out and replace it with a variable that had all of the number 1s, 2s, etc defined in it, and it would just grab them in order when called up. Any help- especially an example script- would be much appreciated, thanks :P

Link to comment
Share on other sites

Func PageSwitcher()
    Dim $x
    For $i = 1 To 10
        Run (@ProgramFilesDir & "\Internet Explorer\iexplore.exe http://www.webpage.com/number" & $i, @ProgramFilesDir & "\Internet Explorer")
        $x = $x + 1
    Next
;Sleep(500); I comment this out but you may need it
EndFunc

Edited by erebus
Link to comment
Share on other sites

erebus has the answer, but if you ever want something LESS automated, you should look at the increment bookmarklet

Details at http://www.squarefree.com/bookmarklets/misc.html

You can put the bookmarklet in your favorites or links toolbar

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...