ดาวน์โหลดไฟล์ จากการอ่านไฟล์ .ini ลองนำไปดัดแปลงให้สามารถดาวน์โหลดได้หลายๆไฟล์กันดูนะครับ
คำคม: สอนวิธีหาปลา ดีกว่า หาปลามาแจก
- Code:
#NoTrayIcon
Local $fileinipath = @DesktopDir&'\Download.ini'
Local $section = 'Section'
Local $keypath = @DesktopDir
Local $valuefile = 'update.dat'
Local $url = 'http://www.autoitscript.com/autoit3/files/beta/update.dat'
Local $destin = @DesktopDir & '\update.dat'
If @IPAddress1 = '127.0.0.1' Then
MsgBox(0, "", "กรุณาต่ออินเทอร์เน็ตและรันใหม่อีกครั้ง.")
Exit
EndIf
If Not FileExists($fileinipath) Then IniWrite($fileinipath, $section, $keypath, $valuefile)
If IniRead($fileinipath, $section, $keypath, Default) = $valuefile Then
Local $sData = InetRead($url)
Local $nBytesRead = @extended
Local $btn = MsgBox(36, "Info file to download", "Filename: " & _
$valuefile & @CRLF & "Bytes read: " & $nBytesRead & _
@CRLF & @CRLF & BinaryToString($sData) & @CRLF&@CRLF&@TAB&@TAB&' '& "ท่านต้องการดาวน์โหลดใช่หรือไม่?")
If $btn = 7 Then Exit
If Not FileExists($destin) Then
Local $hDownload = InetGet($url, $destin, 1, 1)
Local $i = 0
Do
$i += 1
ToolTip("Downloading..Please wait!" & $i & ".sec", 400, 300, "")
Sleep(1000)
Until InetGetInfo($hDownload, 2)
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload)
ToolTip("Download complete."& @CRLF &"File size: " & $nBytes & ".byte"& _
@CRLF &"Use time download:" & $i & ".sec" , 400, 300, "")
Sleep(3000)
ToolTip("")
Exit
Else
MsgBox(4096, "", "มีไฟล์ " & $valuefile & " อยู่ในเครื่องแล้ว ไม่จำเป็นต้องดาวน์โหลดอีก.")
Exit
EndIf
EndIf
คำคม: สอนวิธีหาปลา ดีกว่า หาปลามาแจก