Professional Documents
Culture Documents
Autoit 5643
Autoit 5643
Autoit 5643
Ni dung
n n n n n n
AutoIt
n n
n n n n
n n
Cc v d m u
n
HelloWorld
n
Cc v d m u
n
HelloWorld
n
t tn l helloworld.au3
Cc v d m u
n
HelloWorld
n
Cc v d m u
n
HelloWorld
n
SciTE s c m
Cc v d m u
n
HelloWorld
n
n n n n
Save Kim tra c php :Tool->SyntaxCheck Prod Nhn F5 (Tool -> Go) Kt qu
Cc v d m u
n
Tng tc vi notepad
n n n
To file note.au3 nh v d trn Vo Start -> Run : g notepad M cng c : AutoIt Window Info
n
Cc v d m u
n
Tng tc vi notepad
n
Cc v d m u
n
Tng tc vi notepad
n
Run("notepad.exe")
n
; lnh run s gi file notepad.exe ; i ti khi ca s notepad kch hot(active) ; title : Untitled - Notepad ; gi dng text ti notepad
WinWaitActive("Untitled - Notepad")
n n
Cc v d m u
n
Tng tc vi notepad
n
Kt qu
Cc v d m u
n
Tng tc vi notepad
n
WinClose("Untitled - Notepad")
n
Cc v d m u
n
Tng tc vi notepad
n
Cc v d m u
n
Tng tc vi notepad
n
Send("!n")
n
C php
n
Kiu d liu
n
C php
n
Bin
n
n n n
nh danh:
Khai bo:
n n n
Local Global
V d : Dim $var1
C php
n
Bin
n
Hng
n
Phm vi hot ng
n
Global
n n
Local
n n
C php
n
Bin
n
Mng
n
C php
n
Macros
n n n n
C php
n
Ton t
n
n n n
S hc
=,+=,-=,*=,/=,&=,+,-,*,/,&,^
& : ni 2 chui ^ : m
Logic
n
So snh
n
C php
n
Cu iu kin
n
If...Then...Else
n
$var = 20 If $var > 10 Then MsgBox(0, "Example", "$var was greater than 10!") Else MsgBox(0, "Example", "$var was less than 10") EndIf
C php
n
Cu iu kin
Select...Case
n
$var = 30 Select Case $var > 1 AND $var <= 10 MsgBox(0, "Example", "$var was greater than 1") Case $var > 10 AND $var <= 20 MsgBox(0, "Example", "$var was greater than 10") Case $var > 20 AND $var <= 30 MsgBox(0, "Example", "$var was greater than 20") Case $var > 30 AND $var <= 40 MsgBox(0, "Example", "$var was greater than 30") Case $var > 40 MsgBox(0, "Example", "$var was greater than 40") EndSelect
C php
n
Cu iu kin
Switch...Case
n
$var = 30 Switch Int($var) Case 1 To 10 MsgBox(0, "Example", "$var was greater than 1") Case 11 To 20 MsgBox(0, "Example", "$var was greater than 10") Case 21 To 30 MsgBox(0, "Example", "$var was greater than 20") Case 31 To 40 MsgBox(0, "Example", "$var was greater than 30") Case Else MsgBox(0, "Example", "$var was greater than 40 or less or equal to 0") EndSwitch
C php
n
Vng lp
n
For...To...Step...Next
n
For $i = 5 to 1 Step -1 MsgBox(0, "Count down!", $i) Next MsgBox(0,"", "Blast Off!")
C php
n
Vng lp
n
While...WEnd
n
C php
n
Vng lp
n
Do...Until
n
C php
n
Vng lp n With...EndWith
n
$oExcel = ObjCreate("Excel.Application") $oExcel.visible =1 $oExcel.workbooks.add With $oExcel.activesheet .cells(2,2).value = 1 .range("A1:B2").clear EndWith $oExcel.quit
C php
n
Vng lp
n
For...In...Next
n
For <$Variable> In <expression> statements ... Next Ch lm vic vi mng hay tp i tng
C php
n
Vng lp
n
For...In...Next
n
;Using an Array Dim $aArray[4] $aArray[0]="a" $aArray[1]=0 $aArray[2]=1.3434 $aArray[3]="test" $string = "" FOR $element IN $aArray $string = $string & $element & @CRLF NEXT Msgbox(0,"For..IN Arraytest","Result is: " & @CRLF & $string) ;Using an Object Collection $oShell = ObjCreate("shell.application") $oShellWindows=$oShell.windows if Isobj($oShellWindows) then $string="" for $Window in $oShellWindows $String = $String & $Window.LocationName & @CRLF next msgbox(0,"","You have the following windows open:" & @CRLF & $String) else msgbox(0,"","you have no open shell windows.") endif
C php
n
Hm
n n
nh danh : ging nh bin Func functioname ( [Const] [ByRef] $param1, ..., [Const] [ByRef] $paramN, $optionalpar1 = value, ...) ... [Return [value]] EndFunc V d:
n
$val = 10 For $i = 1 To 10 $doubled = MyDouble($val) MsgBox(0, "", $val & " doubled is " & $doubled) $val = $doubled Next Exit
Mt s th thut
n
Thm #NoTrayIcon vo u file Vista yu cu quyn trc khi thc thi Thm #RequireAdmin vo u file
Cc hm GUI
n n n n n n n
GUICreate() : to ca s lm vic GUICtrlCreate() : to cc control tng ng GUISetState() : hin hay n ca s GUIGetMsg() : ly thng tin v ca s GUICtrlRead() : c d liu t control GUICtrlSetData() : ghi d liu vo control GUICtrlSet(): ghi d liu vo mt s thuc tnh khc ( mu sc , font ch,)
HelloGUI.au3
n
#include <GUIConstantsEx.au3> ;Tao cua so 200x100 voi ten la Hello World GUICreate("Hello World", 200, 100) ;Tao label va button GUICtrlCreateLabel("Hello world! How are you?", 30, 10) GUICtrlCreateButton("OK", 70, 50, 60) ;Hien cua so GUISetState(@SW_SHOW) ;doi 2s Sleep(2000)
Lp trnh s kin
n
AutoIt c 2 ch
n
MessageLoop
n n
L mc nh ca AutoIt Dng hm GUIGetMsg() ly s kin Dng hm Opt("GUIOnEventMode", 1) Dng hm GUICtrlSetOnEvent() to hnh ng cho s kin
OnEvent
n n
Lp trnh s kin
n
MessageLoop
n n n n
GUIGetMsg() s tr v 3 kiu
Khng c s kin : tr v 0 S kin ca control : tr v controlID S kin ca h thng : c khai bo trong GUIConstantsEx.au3 n $GUI_EVENT_CLOSE $GUI_EVENT_MINIMIZE $GUI_EVENT_RESTORE $GUI_EVENT_MAXIMIZE $GUI_EVENT_PRIMARYDOWN $GUI_EVENT_PRIMARYUP $GUI_EVENT_SECONDARYDOWN $GUI_EVENT_SECONDARYUP $GUI_EVENT_MOUSEMOVE $GUI_EVENT_RESIZED $GUI_EVENT_DROPPED
Lp trnh s kin
n
MessageLoop
n n
V d n gin:
#include <GUIConstantsEx.au3> GUICreate("Hello World", 200, 100) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $okbutton MsgBox(0, "GUI Event", "You pressed OK!") Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop EndSelect WEnd
Lp trnh s kin
n
MessageLoop
n
GUIGetMsg(1)
n n n n n n
Tr v mt mng $array[0] = 0 hoc Event ID hoc Control ID $array[1] = ca s ang x l $array[2] = control ang thc thi $array[3] = ta X ca ca s $array[4] = ta Y ca ca s
Lp trnh s kin
n
n
MessageLoop
#include <GUIConstantsEx.au3> $mainwindow = GUICreate("Hello World", 200, 100) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) $dummywindow = GUICreate("Dummy window for testing ", 200, 100) GUISwitch($mainwindow) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $okbutton MsgBox(0, "GUI Event", "You pressed OK!") Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE on the main window! Exiting...") ExitLoop EndSelect WEnd
Lp trnh s kin
n
OnEvent
n
S kin ca control S kin ca h thng GUISetOnEvent() GUICtrlSetOnEvent() Code di v rm r Phi bt option (opt)
Lp trnh s kin
n
OnEvent
n
#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Hello World", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func OKButton() ;Note: at this point @GUI_CTRLID would equal $okbutton, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You pressed OK!") EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") Exit EndFunc
Li kt
n n n
Ti y l bn vng kin thc v AutoIt Nn autoitscript.com hc thm Hy tm tng v th thc hin n bng AutoIT Ti liu ny c bin son t help ca AutoIt Mi kin gp gi v a ch 06Tonline.net@gmail.com