Feature Label Area
Thứ Sáu, 28 tháng 11, 2014
Tagged under:
Code Get Image từ internet!
; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
; #FUNCTION# =========================================================================================================
; Name...........: _GetURLImage
; Description ...: Show an image from the Internet.
;; Syntax.........: _GetURLImage($sURL, [$sDirectory = @ScriptDir])
; $sURL - A valid URL that contains the filename too.
; $sDirectory - [Optional] Directory of where to download to. Default = @ScriptDir
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
; Failure - Returns downloaded filename & sets @error = 1
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include
#include
_Main()
Func _Main()
Local $sFile
GUICreate("_GetURLImage()", 320, 115)
$sFile = _GetURLImage("http://www.matebalazs.hu/upload/upimages/1448.jpg", @TempDir)
If @error = 0 Then
GUICtrlCreatePic($sFile, 0, 0, 320, 115, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) ; Make Sure You Set The Correct Width & Height.
EndIf
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
WEnd
EndFunc ;==>_Main
; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
; #FUNCTION# =========================================================================================================
; Name...........: _GetURLImage
; Description ...: Show an image from the Internet.
;; Syntax.........: _GetURLImage($sURL, [$sDirectory = @ScriptDir])
; $sURL - A valid URL that contains the filename too.
; $sDirectory - [Optional] Directory of where to download to. Default = @ScriptDir
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
; Failure - Returns downloaded filename & sets @error = 1
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
Func _GetURLImage($sURL, $sDirectory = @ScriptDir)
Local $hDownload, $sFile
$sFile = StringRegExpReplace($sURL, "^.*/", "")
If @error Then
Return SetError(1, 0, $sFile)
EndIf
If StringRight($sDirectory, 1) <> "\" Then
$sDirectory = $sDirectory & "\"
EndIf
$sDirectory = $sDirectory & $sFile
If FileExists($sDirectory) Then
Return $sDirectory
EndIf
$hDownload = InetGet($sURL, $sDirectory, 17, 1)
While InetGetInfo($hDownload, 2) = 0
If InetGetInfo($hDownload, 4) <> 0 Then
InetClose($hDownload)
Return SetError(1, 0, $sDirectory)
EndIf
Sleep(105)
WEnd
InetClose($hDownload)
Return $sDirectory
EndFunc ;==>_GetURLImage
Đăng ký:
Bài đăng (Atom)