the_pillo The Magnificent
 Group: Verified Member Joined: 09 Jul 2009 Donor:  Posts: 1105 Gold: 0.00 Clan: Honor

Status: Warn:  Reputation: 32
|
#1 Posted: 07 Oct 2009 02:02 am Post subject: Autoit Basic Tutorial |
|
|
Autoit Quick Tutorial
Ok, so I am feeling very bored and decided it would be fun to make a tutorial.
So i decided to do it with autoit, this will be brief and teach you some basics.
there are much better tutorials out there but this will get you started.
Basic Format:
Command(----,----,----,)
run("notepad.exe")
Common simple functions:
Run
WinWaitactive
winactivate
mouseclick
mousemove
sleep
$
Common Simple Commands
Func...Endfunc
| Code: |
hotkeyset("{end}", "fun")
func fun()
Exit
EndFunc
|
This is an example of the func command.. we declared the command "fun"
To be attached to the END button on your keyboard.
Therefore when we press the END button on the keyboard it will run this
function and EXIT the entire Program.
While...Wend
| Code: |
Run("notepad.exe")
While 1
Send("This is an example of the While...Wend Command")
Wend
|
This is an example of the while Wend command. it will repeat the code between
While and Wend until it becomes true, or forever.
In this script there is no true... so it will type
This is an example of the While...Wend Command
until you end it
If..Then..Endif
| Code: |
$a=10
If $a <> 5 then Exit
Endif
|
This is an example of if then endif, in this it will
find the variable of $a and if it does not equal 5 then it will exit the script.
Select...Case...Endselect
| Code: |
$msg = GuiGetmsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exitloop
Exit
Case $msg = $button_1
run("notepad.exe")
Send("test,test,test")
EndSelect
|
This is an example of select..case..endselect. This command is used
if you have multiple choices, Depending on which case is true will depend what happens.
This was part of a GUI(Graphic User Interface) script,
but when you hit X at the top right of window it would exit the script.
Or if you hit one of the buttons (button 1 for example) it would run notepad and type test.
You must put endselect after you or done to close the command.
VARIABLES:
How to declare variables?
A: Put a $(dollar) sign in front of anything you like... such as $a ,$b, etc.
Then Put and = sign and type what you want your variable to be.
Such as:
| Code: |
$a=5
$b=7
$c=12
If $a+$b <> $c then exit
endif
|
Here is a simple gui script for organizing computer maintenance items.
of course under the run functions on lines: 54,58,and 49 to your own specs.
| Code: |
#include <GUIConstantsEx>
hotkeyset("{end}", "fun")
func fun()
Exit
EndFunc
HotKeySet("{PAUSE}", "TogglePause")
Global $Paused
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("Script is running")
Sleep(2000)
EndFunc
;=====================================================GUI=================================================
Example()
Func Example()
Local $Button_1, $Button_2, $Button_3, $msg
GUICreate("Pillo Productions Presents: Computer Maintenence Center") ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("What would you like to do?",100,30,200)
Opt("GUICoordMode", 2)
$Button_1 = GUICtrlCreateButton("CCleaner", -200, 60, 200)
$Button_2 = GUICtrlCreateButton("Panda Scan", -200, 90)
$Button_3 = GUICtrlCreateButton("Defrag",-200,120)
GUISetState() ; will display an dialog box with 2 button
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
exit
Case $msg = $Button_1
Msgbox(0,"Pillo Productions", "you have started CCleaner")
Run("C:\Program Files\CCleaner\CCleaner.exe")
WinWaitActive("Piriform CCleaner")
Send("{r}")
Case $msg = $Button_2
Msgbox(0,"Pillo Productions", "you have started Panda")
run("C:\Program Files\Panda Security\Panda Antivirus Pro 2009\Pavw.exe")
Winwaitactive("Panda Antivirus Pro 2009 (8.00.00)")
Case $msg = $Button_3
Msgbox(0,"Pillo Productions", "you have started Defrag")
Run ( "C:\WINDOWS\system32\mmc.exe C:\WINDOWS\system32\dfrg.msc" )
Winwaitactive("Disk Defragmenter")
EndSelect
Wend
EndFunc
|
This is confusing but it gives you a small taste of everything ...
Ok i am sorry if this is a crappy tutorial, its my first pure text one. and my first ever on autoit.
tell me what you think and if you think something needs added just ask _____________________
Happiness is a disease, and smiling is the cough that spreads it - pillo-
"When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." |
|