Scan Files Find
เป็นบทเริ่มต้นในการเขียนโปรแกรม AntiVirus และสามารถดัดแปลงนำไปใช้ประโยชน์ด้านอื่นๆอีกหลายอย่าง เช่น การค้นหาไฟล์ที่ต้องการ

Code:
;<----------------start script-------------------<<
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Scan Files Find (*.exe;*.inf)", 323, 400, 192, 124)
GUISetBkColor(0xC0DCC0)
$Input1 = GUICtrlCreateInput("", 16, 48, 209, 21)
$Label1 = GUICtrlCreateLabel("Files path", 100, 24, 49, 17)
$Edit1 = GUICtrlCreateEdit("", 16, 230, 289, 161)
$Label2 = GUICtrlCreateLabel("ScanFiles", 100, 96, 50, 17)
$Button1 = GUICtrlCreateButton("Select", 232, 46, 75, 25, $WS_GROUP)
GUICtrlSetCursor(-1, 0)
$Input2 = GUICtrlCreateInput("", 16, 120, 209, 21)
$Label3 = GUICtrlCreateLabel("FilesList (*.exe;*.inf)", 100, 200, 200, 17)
$Button2 = GUICtrlCreateButton("Scan", 232, 118, 75, 25, $WS_GROUP)
GUICtrlSetCursor(-1, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button3 = GUICtrlCreateButton("Clear", 232, 185, 75, 25, $WS_GROUP)
GUICtrlSetCursor(-1, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			    $filetable = FileSelectFolder("Select Open Directory", "", "", "", "")
			If $filetable Then
				GUICtrlSetData($Input2, '')
			    GUICtrlSetData($Input1, $filetable, Default)
				GUICtrlSetState($Button2, $GUI_ENABLE)
			EndIf
        Case $Button2
			    GUICtrlSetState($Button2, $GUI_DISABLE)
				GUICtrlSetData($Label2, "Scanning...")
			    $search = FileFindFirstFile($filetable & "\*.*")
		    While 1
		        $NextFile =	FileFindNextFile($search)
		        GUICtrlSetData($Input2, $NextFile)
			    If StringInStr($NextFile, '.exe') Or StringInStr($NextFile, '.inf') Then
			        GUICtrlSetData($Edit1, $NextFile & @CRLF, Default)
			    EndIf
			        Sleep(50)
			    If Not $NextFile Then ExitLoop
		    WEnd
		        FileClose($search)
			    GUICtrlSetData($Input2, "Scan completed.")
			    GUICtrlSetData($Label2, "ScannFiles")
			    GUICtrlSetState($Button2, $GUI_DISABLE)
			    GUICtrlSetState($Button3, $GUI_ENABLE)
		Case $Button3
			GUICtrlSetState($Button2, $GUI_DISABLE)
			GUICtrlSetData($Input1, '')
			GUICtrlSetData($Input2, '')
			GUICtrlSetData($Edit1, '')
			GUICtrlSetState($Button3, $GUI_DISABLE)
	EndSwitch
WEnd
;<------------------end script-----------------<<