Senin, 09 Maret 2009

Berkenalan Dengan AutoIt

AutoIt merupakan software yang digunakan untuk membuat suatu program.
AutoIt dapat dikategorikan sebagai bahasa pemrograman karena memiliki
ciri seperti terdapat adanya "if condition". Coding di AutoIt cukup mudah
dan cocok terutama bagi mereka yang baru mempelajari coding di Batch
atau VBS.

Untuk mendownloadnya secara gratis di http://www.autoitscript.com .

Untuk memulai : masuk ke Start Menu - AutoIt v3 - SciTE Script Editor.
Setelah muncul editor tempat kita scripting, pastikan disave terlebih
dahulu dengan format .au3 . Untuk menjalankan program yang telah kita
buat dengan menekan tombol F5. Untuk mebuatnya menjadi exe dengan menekan
tombol F7.

Ok, langsung saja, disini saya akan memberi contoh kode2 yang sering
digunakan saja

- Menulis komentar :
; This is comment

- Menampilkan kotak pesan berisi Hello World dengan judul Tutorial :
MsgBox(0, "Tutorial", "Hello World!")

- Memanggil variabel :
$language = "Hello World!"
MsgBox(0, "Tutorial", $language)

- Situasi kondisi :
$country = "Indonesia"
If $country = "Indonesia" Then
MsgBox(0, "Tutorial", "Yes!")
Else
MsgBox(0, "Tutorial", "No!")
EndIf

- Pengulangan :
For $count = 1 To 5
MsgBox(0, "Tutorial", "Count is: " & $count)
Next

- Pengulangan 2 :
$count = 1
Do
MsgBox(0, "AutoIt Example", "Count is: " & $count)
$count = $count + 1
Until $count > 5

- Pengulangan 3 :
$count = 0
While $count < 5
$count = $count + 1
MsgBox(0, "AutoIt Example", "Count is: " & $count)
Wend

- Input box :
$answer = MsgBox(4, "Tutorial", "Do you like me ?")
If $answer = 7 Then ;If 7 = "No" was clicked
MsgBox(0, "AutoIt", "OK. Bye!")
Else
MsgBox(0, "AutoIt", "OK. Continue!")
EndIf

- Memanggil program :
Run("notepad.exe")

- Menutup program berdasarkan caption :
WinClose("Untitled - Notepad")

- Menutup program berdasarkan nama proses :
ProcessClose ("notepad.exe")

- Mengkopi file :
FileCopy ("C:\zero.exe", "C:\WINDOWS\zero.exe",9)

- Merubah atribut file :
FileSetAttrib ("C:\WINDOWS\zero.exe", "+R+A+S+H")

- Menulis registry :

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","zero", "REG_SZ", "C:\WINDOWS\zero.exe")

- Menulis registry 2 :

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System","DisableRegistryTools", "REG_DWORD", "1")

- Membuat file :
FileWriteLine ("c:\baca.txt", "Hello")
FileWriteLine ("c:\baca.txt", "This is tutorial")

- Sleep
sleep (400)

- Memanggil fungsi :
Func TestFunc1()
MsgBox(0, "Tutorial", "Hello World!")
EndFunc
TestFunc1() ;calling

- Membuat traytip :
TrayTip("Tutorial", "Hello World!", 5, 1)
sleep(2000)

- Mengganti teks di file :
$TextFileName = "TextFile.txt"
$FindText = "replaceMe"
$ReplaceText = "newText"
$FileContents = FileRead($TextFileName)
$FileContents = StringReplace($FileContents,$FindText,$ReplaceText)
FileDelete($TextFileName)
FileWrite($TextFileName,$FileContents)

- Menampilkan informasi drive :
$DriveArray = DriveGetDrive("all")
If Not @error Then
$DriveInfo = ""
For $DriveCount = 1 to $DriveArray[0]
$DriveInfo &= StringUpper($DriveArray[$DriveCount])
$DriveInfo &= " - File System = " &
DriveGetFileSystem($DriveArray[$DriveCount])
$DriveInfo &= ", Label = " & DriveGetLabel($DriveArray[$DriveCount])
$DriveInfo &= ", Serial = " &
DriveGetSerial($DriveArray[$DriveCount])
$DriveInfo &= ", Type = " & DriveGetType($DriveArray[$DriveCount])
$DriveInfo &= ", Free Space = " &
DriveSpaceFree($DriveArray[$DriveCount])
$DriveInfo &= ", Total Space = " &
DriveSpaceTotal($DriveArray[$DriveCount])
$DriveInfo &= ", Status = " & DriveStatus($DriveArray[$DriveCount])
$DriveInfo &= @CRLF
Next
MsgBox(4096,"Drive Info", $DriveInfo)
EndIf

- Menentukan proses sedang berjalan atau tidak :
$ProcessName = "Notepad.exe"
If ProcessExists($ProcessName) Then
MsgBox(0,"Running",$ProcessName & " is running.")
Else
MsgBox(0,"Not Running",$ProcessName & " is not running.")
EndIf

- Membuat angka acak :
$LowerLimit = 29
$UpperLimit = 444
$RandomNumber = Random($LowerLimit,$UpperLimit,1)
MsgBox(0,"Random Number",$RandomNumber)

- Mendownloaad file :
$FileURL = "http://www.anggiawan.web.id/index.htm"
$FileName = "index.htm"
$FileSaveLocation = FileSaveDialog("Location to save
?",@ScriptDir,"All (*.*)",18,$FileName)
$FileSize = InetGetSize($FileURL)
InetGet($FileURL,$FileName,0,1)
ProgressOn("","")
While @InetGetActive
$Percentage = @InetGetBytesRead * 100 / $FileSize
ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " &
$FileSize & " bytes","Downloading " & $FileName)
Sleep(250)
Wend
ProgressOff()
MsgBox(0, "Done","Download Complete!")


Okeh huff.. segitu aja sedikit tutorial coding menggunakan AutoIt,
silahkan dicoba terutama bagi yang masih terperangkap di zone bat / vbs
dan jangan lupa untuk membaca Help nya AutoIt.
Tambahin lagi dong Bro...

sumber:http://www.jasakom.com/

Tidak ada komentar: