Jump to content

Loop variable changing


Recommended Posts

Hi,

I am an absolute noob with Autoit as you will see from my code but if someone can help me it will be muchly appreciated.

Basically im trying to run a task x amount of times but not always at set times, I want to be able specify in minutes the wait time between times that it runs for the first 4 times and then loop them wait times into the amount of times the task runs.

This is what I got so far:

$password = InputBox("Enter Password", "Enter password and click OK", "", "*")

$intervals = InputBox("Updates","How many updates:")

$interval1 = InputBox("Time","Enter first interval in mins:")

$time1 = ($interval1 * 1000 * 60)

;$interval2 = InputBox("Time","Enter second interval in mins:")

;$time2 = ($interval2 * 1000 * 60)

;$interval3 = InputBox("Time","Enter third interval in mins:")

;$time3 = ($interval3 * 1000 * 60)

;$interval4 = InputBox("Time","Enter fourth interval in mins:")

;$time4 = ($interval4 * 1000 * 60)

$times = $intervals

For $i = 1 to $times

sleep (2000)

MouseClick("left", 1371, 321, 1)

sleep (1100)

Send("{CTRLDOWN }")

send ("c")

Send("{CTRLUP }")

MouseClick("left", 58, 337, 1)

sleep (3000)

MouseClick("left", 345, 248, 1)

sleep (500)

Send("{CTRLDOWN }")

send ("v")

Send("{CTRLUP }")

MouseClick("left", 205, 768, 1)

sleep (6000)

MouseClick("left", 390, 597, 1)

sleep (1000)

MouseClick("left", 530, 690, 1)

sleep (1000)

MouseClick("left", 526, 784, 1)

sleep (1000)

MouseClick("left", 554, 738, 1)

sleep (1000)

MouseClick("left", 1700, 313, 1)

sleep (600)

MouseClick("left", 1701, 313, 1)

sleep (1100)

Send("{CTRLDOWN }")

send ("c")

Send("{CTRLUP }")

sleep (1000)

MouseClick("left", 528, 443, 1)

Send("{CTRLDOWN }")

send ("v")

Send("{CTRLUP }")

MouseClick("left", 951, 823, 1)

MouseClick("left", 553, 714, 1)

MouseClick("left", 951, 823, 1)

MouseClick("left", 202, 915, 1)

sleep (2000)

MouseClick("left", 1269, 69, 1)

sleep (700)

MouseClick("left", 1295, 114, 1)

sleep (700)

MouseClick("right", 1295, 114, 1)

sleep (700)

MouseClick("left", 1345, 245, 1)

sleep (2000)

Run ("rundll32.exe user32.dll,LockWorkStation")

sleep ($time1)

run ("c:\Logon.exe -p " & $password)

sleep (5000)

MouseClick("left", 1374, 628, 1)

sleep (7000)

Next

Link to comment
Share on other sites

sleep($time1)

Yes I have that already set near bottom as shown below. Problem is that I need $time1 to be different every time or at least loop a different time at every loop in a loop of 4 times .

$password = InputBox("Enter Password", "Enter password and click OK", "", "*")

$intervals = InputBox("Updates","How many updates:")

$interval1 = InputBox("Time","Enter first interval in mins:")

$time1 = ($interval1 * 1000 * 60)

;$interval2 = InputBox("Time","Enter second interval in mins:")

;$time2 = ($interval2 * 1000 * 60)

;$interval3 = InputBox("Time","Enter third interval in mins:")

;$time3 = ($interval3 * 1000 * 60)

;$interval4 = InputBox("Time","Enter fourth interval in mins:")

;$time4 = ($interval4 * 1000 * 60)

$times = $intervals

For $i = 1 to $times

sleep (2000)

MouseClick("left", 1371, 321, 1)

sleep (1100)

Send("{CTRLDOWN }")

send ("c")

Send("{CTRLUP }")

MouseClick("left", 58, 337, 1)

sleep (3000)

MouseClick("left", 345, 248, 1)

sleep (500)

Send("{CTRLDOWN }")

send ("v")

Send("{CTRLUP }")

MouseClick("left", 205, 768, 1)

sleep (6000)

MouseClick("left", 390, 597, 1)

sleep (1000)

MouseClick("left", 530, 690, 1)

sleep (1000)

MouseClick("left", 526, 784, 1)

sleep (1000)

MouseClick("left", 554, 738, 1)

sleep (1000)

MouseClick("left", 1700, 313, 1)

sleep (600)

MouseClick("left", 1701, 313, 1)

sleep (1100)

Send("{CTRLDOWN }")

send ("c")

Send("{CTRLUP }")

sleep (1000)

MouseClick("left", 528, 443, 1)

Send("{CTRLDOWN }")

send ("v")

Send("{CTRLUP }")

MouseClick("left", 951, 823, 1)

MouseClick("left", 553, 714, 1)

MouseClick("left", 951, 823, 1)

MouseClick("left", 202, 915, 1)

sleep (2000)

MouseClick("left", 1269, 69, 1)

sleep (700)

MouseClick("left", 1295, 114, 1)

sleep (700)

MouseClick("right", 1295, 114, 1)

sleep (700)

MouseClick("left", 1345, 245, 1)

sleep (2000)

Run ("rundll32.exe user32.dll,LockWorkStation")

sleep ($time1) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

run ("c:\Logon.exe -p " & $password)

sleep (5000)

MouseClick("left", 1374, 628, 1)

sleep (7000)

Edited by gamarga
Link to comment
Share on other sites

Try using an array. Something like this. I also modified a couple of your send statements.

$password = InputBox("Enter Password", "Enter password and click OK", "", "*")

$intervals = InputBox("Updates", "How many updates:")

Dim $time[$intervals]
For $i = 0 To $intervals - 1
    $time[$i] = InputBox("Time", "Enter time in mins for interval " & $i) * 1000 * 60
Next

For $i = 0 To $intervals - 1
    Sleep(2000)
    MouseClick("left", 1371, 321, 1)
    Sleep(1100)
    ;Send("{CTRLDOWN }")
    ;send ("c")
    ;Send("{CTRLUP }")
    Send("^c") ;Much easier way to do ctrl+c
    MouseClick("left", 58, 337, 1)
    Sleep(3000)
    MouseClick("left", 345, 248, 1)
    Sleep(500)
    ;Send("{CTRLDOWN }")
    ;send ("v")
    ;Send("{CTRLUP }")

    Send("^v") ;Much easier way to do ctrl+v
    MouseClick("left", 205, 768, 1)
    Sleep(6000)
    MouseClick("left", 390, 597, 1)
    Sleep(1000)
    MouseClick("left", 530, 690, 1)
    Sleep(1000)
    MouseClick("left", 526, 784, 1)
    Sleep(1000)
    MouseClick("left", 554, 738, 1)
    Sleep(1000)
    MouseClick("left", 1700, 313, 1)
    Sleep(600)
    MouseClick("left", 1701, 313, 1)
    Sleep(1100)
    ;Send("{CTRLDOWN }")
    ;send ("c")
    ;Send("{CTRLUP }")
    Send("^c") ;Much easier way to do ctrl+c
    Sleep(1000)
    MouseClick("left", 528, 443, 1)
    Send("^v") ;Much easier way to do ctrl+v
    ;Send("{CTRLDOWN }")
    ;send ("v")
    ;Send("{CTRLUP }")

    MouseClick("left", 951, 823, 1)
    MouseClick("left", 553, 714, 1)

    MouseClick("left", 951, 823, 1)
    MouseClick("left", 202, 915, 1)
    Sleep(2000)
    MouseClick("left", 1269, 69, 1)
    Sleep(700)
    MouseClick("left", 1295, 114, 1)
    Sleep(700)
    MouseClick("right", 1295, 114, 1)
    Sleep(700)
    MouseClick("left", 1345, 245, 1)
    Sleep(2000)

    Run("rundll32.exe user32.dll,LockWorkStation")
    Sleep($time[$i])
    Run("c:\Logon.exe -p " & $password)

    Sleep(5000)
    MouseClick("left", 1374, 628, 1)
    Sleep(7000)

Next

EDIT: corrected this line:

$time[$i] = InputBox("Time", "Enter time in mins for interval " & $i) * 1000 * 60

Edited by TurionAltec
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...