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
;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:
; 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
; 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
; 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
; FOR LOOP
; lets create a FOR LOOP and with a variable initialised to 4 .
; lets then step down in decrements of 1 to positive 1. hence we are counting down from 4 to 1.
;so as soon as we get to the figure we are stepping down to , which in this case is positive one, our statement will break and continue
;to the statement outside the FOR LOOP.
$for_var = 4 for $do_var = 4 to 1 step -1 MsgBox($for_var,"FOR loopS title",$for_var) Next
Result of FOR LOOP
;this will run when the FOR LOOP is exited MsgBox(0, "FOR LOOP COMPLETE" , "BLAST OFF")