четвъртък, 21 април 2011 г.

(Lesson №4) Beep Function

This may be usefull for alerts

Beep Command - Beep (*,*)

Example1:
Beep (1000,3000)
1000 is the frequentie
3000 is 3 seconds, how long the beep is on.

Example2:
MsgBox (0,"Beep”,”Do you want to hear a beep?")
Beep (1000,3000)

(Lesson №3) Loop Functions

Today i will teach you 2 loop functions.

"While 1 /Wend" and "For/Next"

While 1/Wend
While 1
MsgBox (0,"Loop","This is a Loop")
Sleep (1000)
$2 = MsgBox (4,"Exit","Would you like to exit the loop?")

If $2 = 6 Then
ExitLoop
EndIf

If $2 = 7 Then
MsgBox (0,"Ok","Ok")
EndIf

Wend

MsgBox (0, "Exit","You exited the loop")
 Alright, The moment you typed: While 1, the loop starts, if you don’t make a function to exit the loop, You can only exit the program to right click on the right bottom at the autoit icon, and exit script. So first you will get a MsgBox with: This is a Loop, then it will pause 1 second, then you get a choice, if you click Yes you will exit the loop.

If $2 (the name of the MsgBox) = 6 (Yes) Then

ExitLoop (Exit the loop)
EndIf ( Ends the function)

If you click on No you will get a MsgBox with Ok.


If $2 (the name of the MsgBox) = 7 (No) Then

MsgBox (0,"Ok","Ok")
EndIf (Ends the function)

After that you will get to the line “Wend” Wend meands it will go back to while 1, while 1 always needs a wend or it will give an error. No the script will restart.

For/Next

For $i = 5 to 1 Step -1

MsgBox (0, "CountDown", $i)

Next

MsgBox (0, "No Loop","You will get this massage 1 time and then I will exit")
Alright, you wil get 5 times the same massage, and then the script will continue and you will get a other massage. If you change 5 to 10 for example, you will get that msgbox 10 times. So when the script reaches Next it will continue.

(Lesson №2) Sleep Command

The function sleep allows you to pause the script for a while.

Sleep Command - Sleep ()

Example1:
Sleep(1000)
It will sleep (pause) 1000 miliseconds now (that is one second)

Example2:
MsgBox(0,"Hi","This is my MsgBox,the next one will apear 5 secs after closing that one!")
Sleep(5000)

MsgBox(flag,"Boro","Here i am!")

(Lesson №1) MsgBox - Flags & Params

MsgBox Command - MsgBox(flag,"title","text" ,timeout,hwnd)

Params:
Param - Purpose
flag - Sets buttons, icons, etc.
title - Sets the title of the box.
text - Sets the text within the box.
timeout - Sets the number of seconds till close.(Optional)
hwnd - Sets the window handle as the parent.(Optional)

Flags:
Value - Result
0 - OK
1 - OK, Cancel
2 - Abort, Retry, Ignore
3 - Yes, No, Cancel
4 - Yes, No
5 - Retry, Cancel
6 - Cancel, Try Again, Continue (>= Win2k)
16 - Stop Sign Icon
32 - Question Mark Icon
48 - Exclamation Point Icon
64 - Info Bubble Icon
256 - Set Second Button to default
512 - Set Third Button to default
4096 - System modal (dialog has an icon)
8192 - Task modal
262144 - MsgBox ahs top-most attribute set
524288 - Title and Text are right-justified

 

I will give an example:

MsgBox(4,"Answer fast!","Is it OK?",3) ;

The MsgBox will close after 3 seconds
Buttons will be: Yes,No


Hello Everyone!!!

Hi guys! I'm AutoItKid and this blog will be for AutoIt Scripting.
My plan is to teach you how AutoIt works and then i will share with you sources and stuff.
I will post around 5 posts per day ! ^.^

Before every post there will be a:
(Lesson №)Title = Lessons
or

(Source №)Title = Source


Cya!