AutoIT simple tutorial on LOOPS – IF, FOR LOOP, WHILE LOOP, DO LOOP
Autoit is a very simple yet powerful tool to automate simple scripts. Today, we are looking at LOOPS. Credit to 403forbidden403. You can check her on Youtbue
|
1 2 3 4 5 6 7 8 |
;loops ;lets declare a varible $var = 1 ;lets write an if statement if $var = 1 then MsgBox(6,"if Statement Message box","How does the message box look?") endIf |
This is the resulting message box:
|
1 2 3 4 |
; you can keep your if statement on the same one line without ending with an "endif" statment if there is only one message after the "then keyword" ;example, the code below is same as the one above if $var = 1 then MsgBox(6,"if Statement Message box","How does the message box look?") |
And the message box will be same as above
|
1 2 3 4 5 6 7 8 9 10 |
; DO LOOPS ; example lets do SOMETHING until a condition is met and then stop doing that tghint ;whiles our a condition is TRUE $do_var = 3 do MsgBox(3,"do loop title","do loops are awesome") $do_var = $do_var - 1 Until $do_var = 1 |
The result of the DO LOOP
|
1 2 3 4 5 6 7 8 9 10 11 |
; WHILE LOOP ; Let's initialise a variable to 8 ; whiles our variable is not equal to 8, lets create a message box and pop out some message ; and then decrement our variable down. ; as soon as our variable is now equal to 3 , the WHILE LOOP will break and we end the WHILE LOOP with "WEnd" keyword $do_var = 8 while $do_var <> 3 ; whilst it is not equal to 3 , do the following. MsgBox($do_var,"while loop title","while loops are awesome") $do_var = $do_var - 1 WEnd |
Result of WHILE LOOP…
