Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/16/2023 in all areas

  1. Just wanted to add a few: https://github.com/THWillert?tab=repositories (author of FF.au3 and HTML UDFs) https://github.com/nomi-san?tab=repositories https://github.com/tarreislam?tab=repositories (author of AutoIt SOCKET IO UDF) https://github.com/xLinkOut?tab=repositories (author of Telegram UDF) https://github.com/thesunRider?tab=repositories (author of Utter UDF) https://github.com/htejera?tab=repositories (author of AutoIt Monkey UDF) https://github.com/lamnhan066?tab=repositories (author of Flickr API UDF)
    2 points
  2. Hi folks ๐Ÿ‘‹ , I know about several of us do have AutoIt projects on GitHub. In this hopefully growing collection I want to list forum members and their GitHub projects (AutoIt based). Why? One use case could be the contribution to some of their projects. Assume that AutoIt projects are not that wide spreaded or supported in terms of contribution (participation), as JavaScript projects for example. Wouldn't it be nice to get more contribution on your project? Wouldn't it be nice to work on bigger projects in a community? I personally would love to ๐Ÿ˜€ . Disclaimer: As the GitHub profiles (and repositories), I will list here, are public and your profiles either findable by your signature, your "About Me" page or by a simple Google or GitHub search ๐Ÿ” , I see no restriction to collect these kind of information and post it here. In case you don't agree with this visualisation and you don't want to be listet here, please let me know and I will remove that entry as soon as possible ๐Ÿค . I really hope that fits your feeling about it. Collection (in progress): @Forum username ยป GitHub username ยป Link to the GitHub projects (filtered by language=autoit) @Alan72104 ยป Alan72104 ยป Projects @alexanr1 ยป alexanr1 ยป Projects @AspirinJunkie ยป Sylvan86 ยป Projects @Centrally ยป ellysh ยป Projects @Danp2 ยป Danp2 ยป Projects @Danyfirex ยป DanysysTeam ยป Projects @DonChunior ยป DonChunior ยป Projects @ergo ยป seizu ยป Projects @genius257 ยป genius257 ยป Projects @J2TeaM ยป J2TEAM ยป Projects @James ยป jbrooksuk ยป Projects @Jefrey ยป jesobreira ยป Projects @jvanegmond ยป jvanegmond ยป Projects @kurtykurtyboy ยป KurtisLiggett ยป Projects @lamnhan066 ยป lamnhan066 ยป Projects @LinkOut ยป xLinkOut ยป Projects @LoganCH ยป loganch ยป Projects @Mat ยป MattDiesel ยป Projects @Mateocedillo ยป rmcpantoja ยป Projects @matwachich ยป matwachich ยป Projects @mLipok ยป mlipok ยป Projects @MrKm ยป MurageKabui ยป Projects @NHD ยป nomi-san ยป Projects @oHenry ยป htejera ยป Projects @OvisMaximus ยป OvisMaximus ยป Projects @philpw99 ยป philpw99 ยป Projects @rcmaehl ยป rcmaehl ยป Projects @Rurorita ยป OfficialLambdax ยป Projects @rynow ยป 4ern ยป Projects @scintilla4evr ยป scidsgn ยป Projects @seadoggie01 ยป seadoggie01 ยป Projects @seangriffin ยป seanhaydongriffin ยป Projects @smbape ยป smbape ยป Projects @SOLVE-SMART ยป Sven-Seyfert ยป Projects @Stilgar ยป THWillert ยป Projects @Surya ยป thesunRider ยป Projects @tarretarretarre ยป tarreislam ยป Projects @TheDcoder ยป TheDcoder ยป Projects @TheSaint ยป Twombs ยป Projects @trancexx ยป dragana-r ยป Projects @vietanhdev ยป vietanhdev ยป Projects ฮฃ = 41 I would love to see the list growing and I am very excited about a possibly upcoming behavior and improvement change, regarding AutoIt on GitHub ๐Ÿ˜Š . ๐Ÿ’ก Please help me to increase the list. Either by your GitHub link (profile) or through a link from a member you know. Best regards Sven ________________ Stay innovative!
    1 point
  3. Gianni

    Writing hand

    This simple code snippet simulates a writing hand as you type into any input field (hand follows caret) P.S. I don't know what it's for, but I'll post it anyway. .... One possible use would be to draw attention to a message. (such as what I posted here: https://www.autoitscript.com/forum/topic/209396-3202-sraey-wen-yppah/?do=findComment&comment=1510993) Have fun #include <GUIConstants.au3> #include <GDIPlus.au3> Global $iWidth = 100, $iHeight = 70, $iPosX = -1, $iPosY = -1, $aCaretPos, $msg Global $iHandMoves = 2, $iAmplitude = 5, $iHideHidleDelay = 1000, $iFlag = True, $iTimer Global Const $hGUI = GUICreate('', $iWidth, $iHeight, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) Global Const $idLogo = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) _GDIPlus_Startup() Global $Bmp_Logo = _GDIPlus_BitmapCreateFromMemory(_WritingHand(), True) _WinAPI_DeleteObject(GUICtrlSendMsg($idLogo, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp_Logo)) $Bmp_Logo = '' _GDIPlus_Shutdown() While True $aCaretPos = _WinGetCaretPos() If @extended Then $iTimer = TimerInit() $iFlag = True If Not @error Then GUISetState(@SW_SHOWNOACTIVATE, $hGUI) _MoveHand($aCaretPos) EndIf EndIf If $iFlag And (TimerDiff($iTimer) > $iHideHidleDelay) Then GUISetState(@SW_HIDE, $hGUI) $iFlag = False EndIf Sleep(250) WEnd Func _MoveHand($aCaretPos) For $i = 1 To $iHandMoves WinMove($hGUI, '', $aCaretPos[0] + Random(-$iAmplitude, $iAmplitude, 1), $aCaretPos[1] + Random(-$iAmplitude, $iAmplitude, 1), Default, Default, 1) Next WinMove($hGUI, '', $aCaretPos[0], $aCaretPos[1]) EndFunc ;==>_MoveHand ; A more reliable method to retrieve the caret coordinates in MDI Func _WinGetCaretPos() Local Static $iXAdjust = -5, $iYAdjust = -5, $aPrevPos[2] = [0, 0] Local $iOpt = Opt("CaretCoordMode", 0) ; Set "CaretCoordMode" to relative mode and store the previous option. Local $aGetCaretPos = WinGetCaretPos() ; Retrieve the relative caret coordinates. Local $aGetPos = WinGetPos("[ACTIVE]") ; Retrieve the position as well as height and width of the active window. Local $sControl = ControlGetFocus("[ACTIVE]") ; Retrieve the control name that has keyboard focus. Local $aControlPos = ControlGetPos("[ACTIVE]", "", $sControl) ; Retrieve the position as well as the size of the control. $iOpt = Opt("CaretCoordMode", $iOpt) ; Reset "CaretCoordMode" to the previous option. Local $aReturn[2] = [0, 0] ; Create an array to store the x, y position. If IsArray($aGetCaretPos) And IsArray($aGetPos) And IsArray($aControlPos) Then $aReturn[0] = $aGetCaretPos[0] + $aGetPos[0] + $aControlPos[0] + $iXAdjust $aReturn[1] = $aGetCaretPos[1] + $aGetPos[1] + $aControlPos[1] + $iYAdjust ; Check if caret has moved If ($aReturn[0] <> $aPrevPos[0]) Or ($aReturn[1] <> $aPrevPos[1]) Then $aPrevPos[0] = $aReturn[0] $aPrevPos[1] = $aReturn[1] SetError(0, 1) ; if caret has moved set @Extended EndIf Return $aReturn ; Return the array Else Return SetError(1, 0, $aReturn) ; Return the array and set @error to 1. EndIf EndFunc ;==>_WinGetCaretPos ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2020-06-05 Func _WritingHand($bSaveBinary = False, $sSavePath = @ScriptDir) Local $WritingHand $WritingHand &= 'R0lGODlhZABGAHAAACH5BAEAAP8ALAAAAABkAEYAhwAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPVmTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYrM2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlVM5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswAmcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyAM8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8rmf8rzP8r//9VAP9VM/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+qM/+qZv+qmf+qzP+q' $WritingHand &= '///VAP/VM//VZv/Vmf/VzP/V////AP//M///Zv//mf//zP///wAAAAAAAAAAAAAAAAj/APcJHEiwoMGDCBMqXMiwocOH7doNk/iwosWLGBPSk8iuF7uJE4W5y0iypMl9GyNO7CVsmLlhLImdnElTYcqJ7YS1OycxZ85h9GoKrRkxmcSXPHW6HHZOWFOgQ6NmVLmTl9WeVEMybUmMnj5lxIZJEjNJqtmCPYdZ5VWL18SOEdMOmztM2CRJaNBMQhNDjLKzZjcOY8fLHC9bixbZKrz151xJY8VITiNZjKQYNwBLpTfRnC1btRaFLpR4rVWYYcSEGYMmDRrJNzAzKqt5aMpzvBIvKlRICxUtpCUxwoxDjF7KOMLEWB5ji6TaUidarVWI0G8qVbRs2SJmWCaylMXg/8C8fHuYRYx4QR/qrmpoPzGobFFxg8sNMZnofcexJfaW5tmdx0hijAyzHk0bCQNaISvAsJxkaLBm2TCTKNdcGOfpRppokiyi3oEnhXQYGCvc95oYsT0oCS+S9LJiepLY0iGBHC5iIIgl0eOOYO3wIsZ/MajQlySTCNPLMMpIpJYwvDDJ4i6MRBKljH/heBGRw8yjY09MMoLhjQcRA5daa8UYiS1SfmilQ8qIJ0lXG7UnUVOHKXTUYEtaJYmUu0AG5po2KUNZfu10hZVTTP5Z0FIvvVSXVYtJUkt6gFqk4zwSydljUu0gxNFcHzXlYiTCRcKiopUupI87OK30k6OK9v/oFk8gPWoaepKgmmpCrbbzETtNnTNYWkpGpJNSH/WiJ58rqrmrTU1l9dKdL32Uk6hOgdQOS07qiauuzxLU42LG0uoTS9tea2RH1rZkJIvwerjic+EmNG4ttYCkE1Wf0vkSLz6t1K1VZ56Za70HuaNgLYuhxC9WPbnV5Kx4roUJvCzW0myVCA/UjmGLgXlTXDhtS1ijLeXEkmm87PKknx0TJB3ABSkjGKbtcMbOumpJl6eywjQL6WGYyBSz' $WritingHand &= 'QO1pNA8xWAn7kkdqnZsoyy+7dbRD9GzEWU4AA7yURyuTSTVbK4J7tUFJzslztXX12GOepq2osdVnM4SpdCqr3JGROo3/7XKfetbdEI+gHum2RyozOXCztuxii9mCD7Q1SB85muzABE8nCeB0R65RVkqyuxTVaJrmcpOeK5S2tkqB3a2pHsY+NuSRjyzw22MXfBjnawljdOo1gw7qYMryUnDpxrPspO/Aoz1530zZyjKUpmGOevMEzcOqROi2RGfm6elZ/cRr0X42PfMMHzXfVJ8+sdhUm381Z3O5Vbjiyl/V5Mril4+95FkRGNDI55Z19c4qLhPaMH6Hvcl9in1NChb+xoaxJjEQe0maS08Mtz9EsWRlQWOZqcr2v4I8722J41/+ygS4g5VQIOir1VLY1UECzktPGpub/M7Xqrp80CrdkgT+/xL4pClF4kgvREkGHygxZcHvhhlbkalItcP51eqDimsW/OC1okV0iBG7KE0Vj0Y4vmGRixWU2+bMNCAXltCBMGFfnpzUrHlpbBFQAtwYO5Y1GbYEi5OQWAhZyMZaSMmNDdwa91oisSUN8IZSzI2kDMa8/6EPjvbzISPhxsU8Rik0JMTeMrRnFMp9UJMrU6EUwRglSfZpLs3LWs7k4pie8aIXF8NYHdHES/TocI+AggZnFKktltjSlhibIhg71CdTLRN4WSMl02qlpEYCEV4yIpiMPOnMWBJDe+mTi/3M+C4m1bGIm0uPqSyZPneUklh0sWYQiVi1RZRQGUtrxxLngoQoVPKiSGXq3w1feMksaUuDx2QSS87ZP6sk8ZusgiNMPmLLcgZUfPQi6DySlEF9Hcl+WHTixJbnrHvOMhmsoqYmbZkJq+ASaMpKouRQypm7geRIyUIlI/d3PZkqMWffVGkc4/jDivbCpwPRxzALFU6E1oWfxhQiFpEqOY5mSqjGPKU1AwIAOw==' Local $bString = _WinAPI_Base64Decode($WritingHand) If @error Then Return SetError(1, 0, 0) Return Binary($bString) EndFunc ;==>_WritingHand Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc ;==>_WinAPI_Base64Decode
    1 point
  4. - _Download() Automatically select test and select download method. - Support URL redirect - Account and password UDF: #include-once #include <FTPEx.au3> #include <WinAPIEx.au3> #include <String.au3> #include <InetConstants.au3> #include "WinHttp.au3" ;Opt("MustDeclareVars", 1) Opt("TrayAutoPause", 0) If StringInStr(@OSArch, "64") And (Not @AutoItX64) Then _WinAPI_Wow64EnableWow64FsRedirection(0) ; #CONSTANTS# =================================================================================================================== Global Const $ViewLogConsole = 1, $bGetFieSize = 1 Global Const $OPTION_ENABLE_REDIRECTS = 6, $OPTION_USER_AGENT = 0 Global $obError = False, $oErrorHandler = ObjEvent("AutoIt.Error", "__Skip_OBJ_Error") Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") Global $sUSER_AGENT = __WinHttpUA(), $TempDir = @TempDir If Not _Directory_Is_Accessible($TempDir) Then $TempDir = @LocalAppDataDir & "\Temp" If Not _Directory_Is_Accessible($TempDir) Then $TempDir = @ScriptDir EndIf ; =========================================================================================== #comments-start ; Example Global $ftpUserName = "ftpuser@files.trong.live" Global $ftpPassword = "files.trong.live" Global $httpUserName = 'trong' Global $httpPassword = 'autoit' _Download('https://files.trong.live/test.jpg', @ScriptDir & "\testA.jpg") _Download('https://files.trong.live/prv/test.jpg', @ScriptDir & "\testA.jpg", $httpUserName, $httpPassword) _FTP_Download('ftp://files.trong.live/prv/test.jpg', @ScriptDir & "\testB.jpg", $ftpUserName, $ftpPassword) _Download('https://go.microsoft.com/fwlink/?LinkID=2093505', @ScriptDir & "\Microsoft_Edge_Ent_X86.msi") _WinHttp_Download('http://go.microsoft.com/fwlink/?LinkID=2093437', @ScriptDir & "\Microsoft_Edge_Ent_X64.msi") #comments-end ; #CURRENT# ===================================================================================================================== ; _Download() ; _FTP_Download() ; _WinHttp_Download() ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Author... ...........: Dao Van Trong - TRONG.LIVE ; =========================================================================================== Func _Download($sURL_Input, $sLocalPathSAVE, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) $sURL_Input = StringReplace($sURL_Input, "\", "/") If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If ($dProtocol = "ftp" Or $dProtocol = "sftp" Or $dProtocol = "ftps") Then Local $fDL = _FTP_Download($sURL_Input, $sLocalPathSAVE, $dUserName, $dPassword) Return SetError(@error, @extended, $fDL) EndIf If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf If (Not ($dUserName == '')) Then ;$dUserName = StringReplace($dUserName, '@', '%40') If ($dProtocol == 'https' And $dPort <> 443) Or ($dProtocol == 'http' And $dPort <> 80) Then $sURL_Input = $dProtocol & "://" & $dUserName & ":" & $dPassword & "@" & $dDomain & ":" & $dPort & $dURLFilePathName Else $sURL_Input = $dProtocol & "://" & $dUserName & ":" & $dPassword & "@" & $dDomain & $dURLFilePathName EndIf EndIf _LogDebug("- InetGet Download: " & $sURL_Input & " -> " & $sLocalPathSAVE & @CRLF) Local $dlTempFilePath While 1 $dlTempFilePath = $TempDir & "\~download-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "-" & Random(88888888, 99999999, 1) & ".tmp" If (Not FileExists($dlTempFilePath)) Then ExitLoop WEnd $dUserName = StringReplace($dUserName, '%40', '@') Local $sURL_Rediect Local $urlStatus = __URL_Check($sURL_Input, $sURL_Rediect, $dUserName, $dPassword) If @error Then _LogDebug("! /!\ Test connect Error ! " & @CRLF) Return 0 EndIf If ($sURL_Rediect == "") Then Else $sURL_Input = $sURL_Rediect EndIf HttpSetUserAgent($sUSER_AGENT) If $bGetFieSize Then _LogDebug("+ Get file size.... ") $dFileSize = InetGetSize($sURL_Input) If @error Then _LogDebug(" ERROR !" & @CRLF) Else _LogDebug(" OK -> " & _Byte_GetDisplay($dFileSize) & " " & @CRLF) EndIf EndIf _LogDebug("+ Downloading.... ") Local $hDownload = InetGet($sURL_Input, $dlTempFilePath, 1 + 2 + 16, 1) Local $Percentage = 0, $Old_Percentage = 0, $TotalToDownload = 0, $BytesDownloaded = 0, $DownloadedSoFar = 0, $pCheck = 0 Do Sleep(100) If $dFileSize > 0 Then ; Get number of bytes read for current file $BytesDownloaded = InetGetInfo($hDownload, 0) ; Add this to the cumulative total $DownloadedSoFar = $TotalToDownload + $BytesDownloaded ; Calculate the current file percentage $Percentage = Floor(($BytesDownloaded / $dFileSize) * 100) ; Only update the current file percent label if it has changed to avoid flickering If ($Percentage - $Old_Percentage) > 4 Then _LogDebug($Percentage & "% ") $Old_Percentage = $Percentage EndIf EndIf Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. ;Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) ;Local $iFileSize = FileGetSize($dlTempFilePath) ;ConsoleWrite("- Downloaded: " & $iBytesSize & " KB/s " & @CRLF) ;ConsoleWrite("- File Size: " & $iFileSize & " KB/s " & @CRLF) Local $aDownloadData = InetGetInfo($hDownload) InetClose($hDownload) If ($aDownloadData[$INET_DOWNLOADSUCCESS] And FileExists($dlTempFilePath)) Then _LogDebug("- DONE !" & @CRLF) __File_SAVE($dlTempFilePath, $sLocalPathSAVE) If FileExists($sLocalPathSAVE) Then _LogDebug("+ Save file to: " & $sLocalPathSAVE & " OK !" & @CRLF) Else _LogDebug("! Save file to: " & $sLocalPathSAVE & " ERROR !" & @CRLF) EndIf Else _LogDebug(" ERROR " & @CRLF) _LogDebug("- Try Download again with WinHttp !" & @CRLF) Return _WinHttp_Download($sURL_Input, $sLocalPathSAVE) EndIf EndFunc ;==>_Download Func _WinHttp_Download($sURL_Input, $sLocalPathSAVE, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If ($dProtocol = "ftp" Or $dProtocol = "sftp" Or $dProtocol = "ftps") Then Local $fDL = _FTP_Download($sURL_Input, $sLocalPathSAVE, $dUserName, $dPassword) Return SetError(@error, @extended, $fDL) EndIf If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf _LogDebug("+ WinHttp Download: " & $sURL_Input & " -> " & $sLocalPathSAVE & @CRLF) Local $sURL_Rediect Local $urlStatus = __URL_Check($sURL_Input, $sURL_Rediect, $dUserName, $dPassword) If @error Then _LogDebug("! /!\ Test connect Error ! " & @CRLF) Return 0 EndIf If ($sURL_Rediect == "") Then Else $sURL_Input = $sURL_Rediect EndIf Local $dlTempFilePath While 1 $dlTempFilePath = $TempDir & "\~download-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "-" & Random(88888888, 99999999, 1) & ".tmp" If (Not FileExists($dlTempFilePath)) Then ExitLoop WEnd ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Set User-Agent string _WinHttpSetOption($hOpen, $WINHTTP_OPTION_USER_AGENT, $sUSER_AGENT) ; Get connection handle _LogDebug("- WinHttp Connecting ...") Local $hConnect = _WinHttpConnect($hOpen, $dDomain) If @error Then _LogDebug(" ERROR " & @error & @CRLF) Return SetError(1, 0, 0) EndIf _LogDebug(" OK" & @CRLF & "- WinHttp Downloading ...") ; SimpleSSL-request it... Local $vReturned If (($dProtocol = "https") Or ($dPort = 443)) Then $vReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $dURLFilePathName, $dProtocol & "://" & $dDomain, $WINHTTP_NO_REQUEST_DATA, $WINHTTP_NO_ADDITIONAL_HEADERS, False, 2, $dUserName, $dPassword) Else $vReturned = _WinHttpSimpleRequest($hConnect, "GET", $dURLFilePathName, $dProtocol & "://" & $dDomain, $WINHTTP_NO_REQUEST_DATA, $WINHTTP_NO_ADDITIONAL_HEADERS, False, 2, $dUserName, $dPassword) EndIf If @error Then _LogDebug("! Request ERROR " & @error & @CRLF) Return SetError(2, 0, 0) EndIf _LogDebug(" OK" & @CRLF & "- Saving to file ...") ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If FileExists($sLocalPathSAVE) Then _DelIt($sLocalPathSAVE, 1) Local $iDirFile = _Path_Split($sLocalPathSAVE, 6) If Not FileExists($iDirFile) Then DirCreate($iDirFile) Local $DataLen = BinaryLen($vReturned) Local $hFile = FileOpen($sLocalPathSAVE, 2 + 8 + 16) FileWrite($hFile, $vReturned) FileClose($hFile) If FileExists($sLocalPathSAVE) Then _LogDebug(" OK (Size: " & _Byte_GetDisplay($DataLen) & ") file: " & $sLocalPathSAVE & @CRLF) Return 1 Else _LogDebug(" ERROR (Size: " & _Byte_GetDisplay($DataLen) & ") file: " & $sLocalPathSAVE & @CRLF) Return SetError(1, 0, 0) EndIf EndFunc ;==>_WinHttp_Download Func _FTP_Download($sURL_Input, $sLocalPathSAVE, $dUserName = "anonymous", $dPassword = "") _LogDebug("+ FTP Download: " & $sURL_Input & " -> " & $sLocalPathSAVE & @CRLF) If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'ftp://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) #cs ConsoleWrite("- Protocol : " & $dProtocol & @CRLF) ConsoleWrite("- Domain : " & $dDomain & @CRLF) ConsoleWrite("- Port : " & $dPort & @CRLF) ConsoleWrite("- User : " & $dUser & @CRLF) ConsoleWrite("- Password : " & $dPass & @CRLF) ConsoleWrite("- FilePathName: " & $dURLFilePathName & @CRLF) ConsoleWrite("- FilePath : " & $dURLFilePath & @CRLF) ConsoleWrite("- FileName : " &$dURLFileName & @CRLF) #ce If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "")) Then $dUserName = "anonymous" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf Local $Err, $sFTP_Message, $iReturn = 0, $iError = 0 Local $dlTempFilePath = $TempDir & "\~download.tmp" While 1 $dlTempFilePath = $TempDir & "\~download-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "-" & Random(88888888, 99999999, 1) & ".tmp" If (Not FileExists($dlTempFilePath)) Then ExitLoop WEnd If $bGetFieSize Then _LogDebug("- FTP Getting the file size... " & @CRLF) $dFileSize = _Byte_GetDisplay(__FTP_FileGetSize($sURL_Input, $dUserName, $dPassword)) EndIf ;_LogDebug("-Protocol: " & $dProtocol & @CRLF) ;_LogDebug("-Server: " & $dDomain & @CRLF) ;_LogDebug("-User: '" & $dUserName & "'" & @CRLF) ;_LogDebug("-Password: '" & $dPassword & "'" & @CRLF) ;_LogDebug("-RemoteFile: " & $dURLFilePathName & @CRLF) If $dFileSize > 0 Then _LogDebug("- File Size: " & $dFileSize & @CRLF) Else _LogDebug("! An error occurred, Getting the file size failed!" & @CRLF) EndIf _LogDebug("- FTP Getting the file ... " & @CRLF) Local $hOpen = _FTP_Open('FTP_Client', $INTERNET_OPEN_TYPE_DIRECT) If @error Then Return SetError(1, 0, 0) Local $hFTPSession = _FTP_Connect($hOpen, $dDomain, $dUserName, $dPassword) If @error Then Local $WinHTTP_Error_Return = @extended Local $WinHTTP_Error_Name = _WinHTTP_GetName_ErrorCode($WinHTTP_Error_Return) _LogDebug('! _FTP_Connect Error: ' & @error & " - Extended: " & $WinHTTP_Error_Return & @CRLF) _LogDebug('! WinHTTP Error: ' & $WinHTTP_Error_Name & @CRLF) If ($WinHTTP_Error_Return = 12029) Then _LogDebug('! Error: A connection with the server could not be established' & @CRLF) If ($WinHTTP_Error_Return = 12014) Then _LogDebug('! Error: The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect.' & @CRLF) Return SetError(2, $WinHTTP_Error_Return, 0) EndIf If $bGetFieSize Then _LogDebug("- Downloading " & $dURLFilePathName & " (" & $dFileSize & ") " & " ..." & @CRLF) Else _LogDebug("- Downloading " & $dURLFilePathName & " ...") EndIf Local $fuFunctionToCall = __FTPGetFile_UpdateProgress Local $iFDL = _FTP_ProgressDownload($hFTPSession, $dlTempFilePath, $dURLFilePathName, $fuFunctionToCall) Local $iErr, $sFTP_Message If (Not FileExists($dlTempFilePath)) Then _FTP_GetLastResponseInfo($iErr, $sFTP_Message) _LogDebug('! ERROR ! Code: [' & $Err & '] FTP_Message: [' & @CRLF & $sFTP_Message & "]" & @CRLF) _FTP_Close($hFTPSession) _FTP_Close($hOpen) $hOpen = _FTP_Open('FTP_Client', $INTERNET_OPEN_TYPE_DIRECT) $hFTPSession = _FTP_Connect($hOpen, $dDomain, $dUserName, $dPassword) If @error Then Local $WinHTTP_Error_Return = @extended Local $WinHTTP_Error_Name = _WinHTTP_GetName_ErrorCode($WinHTTP_Error_Return) _LogDebug('! _FTP_Connect Error: ' & @error & " - Extended: " & $WinHTTP_Error_Return & @CRLF) _LogDebug('! WinHTTP Error: ' & $WinHTTP_Error_Name & @CRLF) If ($WinHTTP_Error_Return = 12029) Then _LogDebug('! Error: A connection with the server could not be established' & @CRLF) If ($WinHTTP_Error_Return = 12014) Then _LogDebug('! Error: The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect.' & @CRLF) Return SetError(2, $WinHTTP_Error_Return, 0) EndIf $iFDL = _FTP_FileGet($hFTPSession, $dURLFilePathName, $dlTempFilePath, False, Default, $FTP_TRANSFER_TYPE_BINARY) If (Not FileExists($dlTempFilePath)) Then _FTP_GetLastResponseInfo($iErr, $sFTP_Message) _LogDebug('! ERROR ! Code: [' & $Err & '] FTP_Message: [' & @CRLF & $sFTP_Message & "]" & @CRLF) _FTP_Close($hFTPSession) _FTP_Close($hOpen) Return SetError(3, 0, 0) Else _LogDebug('+ OK !' & @CRLF) EndIf Else _LogDebug('+ OK !' & @CRLF) EndIf _FTP_Close($hFTPSession) _FTP_Close($hOpen) __File_SAVE($dlTempFilePath, $sLocalPathSAVE) If FileExists($sLocalPathSAVE) Then _LogDebug("+ Save file to: " & $sLocalPathSAVE & " OK !" & @CRLF) Return SetError(0, 0, 1) Else _LogDebug("! Save file to: " & $sLocalPathSAVE & " ERROR !" & @CRLF) Return SetError(4, 0, 0) EndIf EndFunc ;==>_FTP_Download Func __FTPGetFile_UpdateProgress($iPercent) _LogDebug(" " & Int($iPercent) & "%" & ' ') ;If _IsPressed("77") Then Return 0 ; Abort on F8 Return 1 ; 1 to continue Download EndFunc ;==>__FTPGetFile_UpdateProgress Func __FTP_FileGetSize($sURL_Input, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'ftp://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "")) Then $dUserName = "anonymous" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf Local $hOpen = _FTP_Open('FTP_Client') If @error Then Return SetError(1, 0, "") Local $hConn = _FTP_Connect($hOpen, $dDomain, $dUserName, $dPassword) If @error Then Local $WinHTTP_Error_Return = @extended Local $WinHTTP_Error_Name = _WinHTTP_GetName_ErrorCode($WinHTTP_Error_Return) _LogDebug('! _FTP_Connect Error: ' & @error & " - Extended: " & $WinHTTP_Error_Return & @CRLF) _LogDebug('! WinHTTP Error: ' & $WinHTTP_Error_Name & @CRLF) If ($WinHTTP_Error_Return = 12029) Then _LogDebug('! Error: A connection with the server could not be established' & @CRLF) If ($WinHTTP_Error_Return = 12014) Then _LogDebug('! Error: The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect.' & @CRLF) Return SetError(2, $WinHTTP_Error_Return, 0) EndIf Local $iFileSize = _FTP_FileGetSize($hConn, $dURLFilePathName) If @error Then Return SetError(3, 0, "") ;ConsoleWrite('$sFilenameNext1 = ' & $dFileName & ' size = ' & $iFileSize & ' -> Error code: ' & @error & ' extended: ' & @extended & @CRLF) Local $iErr, $sMessage Local $iFtpr = _FTP_GetLastResponseInfo($iErr, $sMessage) ; no error ;ConsoleWrite('$sMessage = ' & $sMessage & ' err = ' & $iErr & ' -> Error code: ' & @error & ' extended: ' & @extended & @CRLF) Local $iFtpc = _FTP_Close($hConn) Local $iFtpo = _FTP_Close($hOpen) Return $iFileSize EndFunc ;==>__FTP_FileGetSize Func __File_SAVE($dlTempFilePath, $sLocalPathSAVE) If Not FileExists($dlTempFilePath) Then _LogDebug("! Source path is not File Exists: " & $dlTempFilePath & @CRLF) Return SetError(1, 0, -1) EndIf _LogDebug("- Move (" & FileExists($dlTempFilePath) & ") " & $dlTempFilePath & " >TO> " & $sLocalPathSAVE & " > ") If FileExists($sLocalPathSAVE) Then _DelIt($sLocalPathSAVE, 1) Local $iDirFile = _Path_Split($sLocalPathSAVE, 6) If Not FileExists($iDirFile) Then DirCreate($iDirFile) If FileMove($dlTempFilePath, $sLocalPathSAVE, 1) Then _DelIt($dlTempFilePath, 1) _LogDebug(" Move OK" & @CRLF) Return 1 Else _LogDebug(" ERROR !" & @CRLF & @CRLF) _LogDebug("- Try Copy (" & FileExists($dlTempFilePath) & ") " & $dlTempFilePath & " >TO> " & $sLocalPathSAVE & " > ") If FileCopy($dlTempFilePath, $sLocalPathSAVE, 1) Then _DelIt($dlTempFilePath, 1) _LogDebug(" OK" & @CRLF) Return 1 Else _LogDebug(" ERROR !" & @CRLF & @CRLF) Return 0 EndIf EndIf EndFunc ;==>__File_SAVE Func _Encode_URL($UnicodeURL) Local $UnicodeBinary = StringToBinary($UnicodeURL, 4) Local $UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1) Local $UnicodeBinaryLength = StringLen($UnicodeBinary2) Local $EncodedString, $UnicodeBinaryChar For $i = 1 To $UnicodeBinaryLength Step 2 $UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2) If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString('0x' & $UnicodeBinaryChar, 4)) Then $EncodedString &= BinaryToString('0x' & $UnicodeBinaryChar) Else $EncodedString &= '%' & $UnicodeBinaryChar EndIf Next Return $EncodedString EndFunc ;==>_Encode_URL Func _Decode_URL($toDecode) Local $strChar = "", $iOne, $iTwo Local $aryHex = StringSplit($toDecode, "") For $i = 1 To $aryHex[0] If $aryHex[$i] = "%" Then $i = $i + 1 $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $strChar = $strChar & Chr(Dec($iOne & $iTwo)) Else $strChar = $strChar & $aryHex[$i] EndIf Next Local $Process = StringToBinary(StringReplace($strChar, "+", " ")) Local $DecodedString = BinaryToString($Process, 4) Return $DecodedString EndFunc ;==>_Decode_URL Func __URL_Status($sURL_Input, ByRef $sURL_Rediect, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf If (Not ($dUserName == '')) Then If ($dProtocol == 'https' And $dPort <> 443) Or ($dProtocol == 'http' And $dPort <> 80) Then $sURL_Input = $dProtocol & "://" & $dDomain & ":" & $dPort & $dURLFilePathName Else $sURL_Input = $dProtocol & "://" & $dDomain & $dURLFilePathName EndIf EndIf $oHTTP.Option($OPTION_USER_AGENT) = $sUSER_AGENT $oHTTP.Option($OPTION_ENABLE_REDIRECTS) = False $oHTTP.Open("HEAD", $sURL_Input, False) If @error Then Return SetError(1, @error, -1) If (StringLen(StringStripWS($dUserName, 8)) > 1) Then $oHTTP.SetCredentials($dUserName, $dPassword, 0) $oHTTP.Send() If @error Then Return SetError(2, @error, 105) ;Error 105 (net::ERR_NAME_NOT_RESOLVED) Local $oStatus = $oHTTP.Status If @error Then Return SetError(3, @error, 118) ;Error 118 (net::ERR_CONNECTION_TIMED_OUT) If (($oStatus = 301) Or ($oStatus = 302)) Then $sURL_Rediect = $oHTTP.GetResponseHeader("Location") _LogDebug("! Redirect to URL: " & $sURL_Rediect & @CRLF) EndIf ;_LogDebug("+ GetResponseHeader: " & $oStatus & @CRLF) ;_LogDebug("- Cache-Control: " & $oHTTP.GetResponseHeader("Cache-Control") & @CRLF) ;_LogDebug("- Connection: " & $oHTTP.GetResponseHeader("Connection") & @CRLF) ;_LogDebug("- Date: " & $oHTTP.GetResponseHeader("Date") & @CRLF) ;_LogDebug("- Keep-Alive: " & $oHTTP.GetResponseHeader("Keep-Alive") & @CRLF) _LogDebug("- Content-Length: " & _Byte_GetDisplay($oHTTP.GetResponseHeader("Content-Length")) & @CRLF) ;_LogDebug("- Content-Type: " & $oHTTP.GetResponseHeader("Content-Type") & @CRLF) ;_LogDebug("- Expires: " & $oHTTP.GetResponseHeader("Expires") & @CRLF) ;_LogDebug("- Last-Modified: " & $oHTTP.GetResponseHeader("Last-Modified") & @CRLF) ;_LogDebug("- Accept-Ranges: " & $oHTTP.GetResponseHeader("Accept-Ranges") & @CRLF) ;_LogDebug("- Server: " & $oHTTP.GetResponseHeader("Server") & @CRLF) ;_LogDebug("- WWW-Authenticate: " & $oHTTP.GetResponseHeader("WWW-Authenticate") & @CRLF) ;_LogDebug($oHTTP.getAllResponseHeaders() & @CRLF) $oHTTP.Option($OPTION_ENABLE_REDIRECTS) = True Return SetError(0, 0, $oStatus) EndFunc ;==>__URL_Status Func _Check_Connect($iDomain, $iPort = 80) Opt("TCPTimeout", 3000) TCPStartup() _LogDebug("- Checking Domain: " & $iDomain & " | Port: " & $iPort & " ") Local $sIPAddress = TCPNameToIP($iDomain) _LogDebug(" -> IP Address: " & $sIPAddress) Local $iSocket = TCPConnect($sIPAddress, $iPort) If $iSocket < 1 Then _LogDebug(" -> ERROR !" & @CRLF) Return SetError(1, 0, 0) Else _LogDebug(" -> SK:" & $iSocket & " OK !" & @CRLF) Return SetError(0, 0, 1) EndIf TCPShutdown() Opt("TCPTimeout", 250) EndFunc ;==>_Check_Connect Func __URL_Check($sURL_Input, ByRef $sURL_Rediect, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) #cs ConsoleWrite("- Protocol : " & $dProtocol & @CRLF) ConsoleWrite("- Domain : " & $dDomain & @CRLF) ConsoleWrite("- Port : " & $dPort & @CRLF) ConsoleWrite("- User : " & $dUser & @CRLF) ConsoleWrite("- Password : " & $dPass & @CRLF) ConsoleWrite("- FilePathName: " & $dURLFilePathName & @CRLF) ConsoleWrite("- FilePath : " & $dURLFilePath & @CRLF) ConsoleWrite("- FileName : " &$dURLFileName & @CRLF) #ce If $dPort > 0 Then If _Check_Connect($dDomain, $dPort) = 0 Then Return SetError(1, 0, 0) Else Switch $dProtocol Case "http" If (_Check_Connect($dDomain, 80) = 0) Then Return SetError(1, 0, 0) Case "https" If (_Check_Connect($dDomain, 443) = 0) Then Return SetError(1, 0, 0) Case "ftp", "ftps" If (_Check_Connect($dDomain, 21) = 0) Then Return SetError(1, 0, 0) Case "sftp" If (_Check_Connect($dDomain, 22) = 0) Then Return SetError(1, 0, 0) EndSwitch EndIf Local $urlStatus = __URL_Status($sURL_Input, $sURL_Rediect, $dUserName, $dPassword) Switch $urlStatus Case 301, 302 If ($sURL_Rediect == "") Then Else $sURL_Input = $sURL_Rediect EndIf _LogDebug("- URL Status: " & $urlStatus & " > Connection Successful! (URL redirect to: " & $sURL_Input & ")" & @CRLF) Return SetError(0, 0, __URL_Check($sURL_Input, $sURL_Rediect, $dUserName, $dPassword)) Case 200 _LogDebug("- URL Status: " & $urlStatus & " > Connection Successful! (URL: " & $sURL_Input & ")" & @CRLF) Return SetError(0, 0, $urlStatus) Case 401, 407 _LogDebug("- URL Status: " & $urlStatus & " > Connection error! > Unauthorized (URL: " & $sURL_Input & ")" & @CRLF) Case 404 _LogDebug("- URL Status: " & $urlStatus & " > Connection Successful! > URL Not Found: " & $sURL_Input & @CRLF) Case 105 _LogDebug("- URL Status: " & $urlStatus & " > Connection error: ERR_NAME_NOT_RESOLVED > URL is Not Found: " & $sURL_Input & @CRLF) Case Else _LogDebug("- URL Status: " & $urlStatus & " > Connection error! > URL: " & $sURL_Input & @CRLF) EndSwitch Return SetError(1, 0, $urlStatus) EndFunc ;==>__URL_Check Func _Byte_GetDisplay($iSize, $iPlaces = 4) Local $aBytes[7] = [' Bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB'] For $i = 6 To 1 Step -1 If $iSize >= 1024 ^ $i Then Return Round($iSize / 1024 ^ $i, $iPlaces) & $aBytes[$i] EndIf Next Return $iSize & ' Bytes' EndFunc ;==>_Byte_GetDisplay Func _Convert_Size($inputSize, $inputUnit = 0, $outputPlaces = 2, $outputString = True, $inputBits = False, $outputBits = False, $outputUnit = -4) Local $unitNames[9] = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"] Local $Bytes = $inputSize * 1024 ^ $inputUnit Local $b = "B" If $inputBits Then $Bytes /= 8 If $outputBits Then $Bytes *= 8 $b = "b" EndIf If $outputUnit < 0 Then Local $outputMax = Abs($outputUnit) $outputUnit = Int(Log($Bytes) / Log(1024)) If $outputUnit > $outputMax Then $outputUnit = $outputMax EndIf If $outputString Then Return String(Round($Bytes / 1024 ^ $outputUnit, $outputPlaces)) & " " & $unitNames[$outputUnit] & $b Else Return Round($Bytes / 1024 ^ $outputUnit, $outputPlaces) EndIf EndFunc ;==>_Convert_Size Func _Path_Split($sFilePath, $sType = 0) Local $sDrive, $sDir, $sFileName, $sExtension, $sReturn Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1) If @error Then ReDim $aArray[5] $aArray[0] = $sFilePath EndIf $sDrive = $aArray[1] If StringLeft($aArray[2], 1) == "/" Then $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\/") Else $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\\") EndIf $aArray[2] = $sDir $sFileName = $aArray[3] $sExtension = $aArray[4] If $sType = 1 Then Return $sDrive If $sType = 2 Then Return $sDir If $sType = 3 Then Return $sFileName If $sType = 4 Then Return $sExtension If $sType = 5 Then Return $sFileName & $sExtension If $sType = 6 Then Return $sDrive & $sDir If $sType = 7 Then Return $sDrive & $sDir & $sFileName Return $aArray EndFunc ;==>_Path_Split Func _IsFile($sPath) If (Not FileExists($sPath)) Then Return SetError(-1, 0, 0) If StringInStr(FileGetAttrib($sPath), 'D') <> 0 Then Return SetError(0, 0, 0) Else Return SetError(0, 0, 1) EndIf EndFunc ;==>_IsFile Func _DelIt($sPath, $Fc = 1) If (Not FileExists($sPath)) Then Return SetError(-1, 0, 1) If _IsFile($sPath) Then Return SetError(0, 0, _DelFile($sPath, $Fc)) Else Return SetError(0, 0, _RemoveDir($sPath, $Fc)) EndIf EndFunc ;==>_DelIt Func _DelFile($sPath, $Fc = 1) If (Not _IsFile($sPath)) Then Return SetError(-1, 0, 0) Else FileSetAttrib($sPath, "-RSH") FileDelete($sPath) If $Fc Then If FileExists($sPath) Then _TakeOwnership($sPath, "Everyone", $Fc) If FileExists($sPath) Then FileDelete($sPath) If FileExists($sPath) Then RunWait(@ComSpec & ' /c Del /f /q "' & $sPath & '"', '', @SW_HIDE) EndIf If FileExists($sPath) Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndIf EndFunc ;==>_DelFile Func _RemoveDir($sPath, $Fc = 1) If _IsFile($sPath) Then Return SetError(-1, 0, 0) Else DirRemove($sPath, $Fc) If FileExists($sPath) Then _TakeOwnership($sPath, "Everyone", $Fc) DirRemove($sPath, $Fc) If FileExists($sPath) Then RunWait(@ComSpec & ' /c rmdir "' & $sPath & '" /s /q ', '', @SW_HIDE) If FileExists($sPath) Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndIf EndFunc ;==>_RemoveDir Func _GetDomainURL($sURL_Input) Local $sURL_Pattern = "^(?i)(?:(?:[a-z]+):\/\/)?" & _ ; Protocol "(?:(?:(?:[^@:]+))" & _ ; Username "(?::(?:[^@]+))?@)?" & _ ; Password "([^\/:]+)" & _ ; Host "(?::(?:\d+))?" & _ ; Port "(?:\/(?:[^?]+)?)?" & _ ; Path "(?:\?\N+)?" ; Query Local $aHost = StringRegExp($sURL_Input, $sURL_Pattern, 1) If IsArray($aHost) Then Return $aHost[0] Return "" EndFunc ;==>_GetDomainURL Func _LogDebug($iLog = "", $iLogs = "", $itype = -1) If (($itype = 0) And ($iLog = "") And ($iLogs = "")) Then Return 0 If (($itype = -1) And $ViewLogConsole) Then Return ConsoleWrite($iLog) If ($iLogs = "") Then $iLogs = $iLog If ($itype = 0) Then If $ViewLogConsole Then ConsoleWrite("- " & $iLog & @CRLF) ;If $sTextColor <> $lBkColor Then ;$sTextColor = $lBkColor ;GUICtrlSetColor($labStatus, $sTextColor) ;EndIf ;GUICtrlSetData($labStatus, $iLogs) Else If $ViewLogConsole Then ConsoleWrite("! " & $iLog & @CRLF) ;If $sTextColor <> $sTextColorError Then ;$sTextColor = $sTextColorError ;GUICtrlSetColor($labStatus, $sTextColor) ;EndIf ;GUICtrlSetData($labStatus, $iLogs) EndIf Return 1 EndFunc ;==>_LogDebug Func __Skip_OBJ_Error() $obError = True ;ConsoleWrite("! " & $obError.description & @CRLF) EndFunc ;==>__Skip_OBJ_Error Func _WinHttpURL_GetStatus($sURL_Input, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, $dDomain) ; Specify the reguest Global $hRequest = _WinHttpOpenRequest($hConnect, "HEAD", $dURLFilePathName, Default, $dProtocol & "://" & $dDomain) ; Set credentials If (StringLen(StringStripWS($dUserName, 8)) > 1) Then _WinHttpSetCredentials($hRequest, $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_BASIC, $dUserName, $dPassword) ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) ; Get full header Global $sHeader = _WinHttpQueryHeaders($hRequest) ConsoleWrite($sHeader & @CRLF) ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) EndFunc ;==>_WinHttpURL_GetStatus Func _Directory_Is_Accessible($sPath, $iTouch = 0) If Not FileExists($sPath) Then DirCreate($sPath) If Not StringInStr(FileGetAttrib($sPath), "D", 2) Then Return SetError(1, 0, 0) Local $iEnum = 0, $maxEnum = 9999, $iRandom = Random(88888888, 99999999, 1) If $iTouch Then _TakeOwnership($sPath, "Everyone", 1) While FileExists($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom) $iEnum += 1 If ($iEnum > $maxEnum) Then Return SetError(2, 0, 0) WEnd Local $iSuccess = DirCreate($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom) Switch $iSuccess Case 1 $iTouch = DirRemove($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom, 1) Return SetError($iTouch < 1, 0, $iTouch) Case Else Return SetError(3, 0, 0) EndSwitch EndFunc ;==>_Directory_Is_Accessible Func _File_Is_Accessible($sFile, $iTouch = 0) ; Returns ; 1 = Success, file is writeable and deletable ; 2 = Access Denied because of lacking access rights OR because file is open by another process ; 3 = File is set "Read Only" by attribute ; 0 = File not found or Is Directory If ((Not FileExists("\\?\" & $sFile)) Or StringInStr(FileGetAttrib("\\?\" & $sFile), "D", 2)) Then Return SetError(1, 0, 0) Local $oFileAttrib = FileGetAttrib("\\?\" & $sFile) If $iTouch Then FileSetAttrib("\\?\" & $sFile, "-RHS") _TakeOwnership($sFile, "Everyone", 1) EndIf If StringInStr(FileGetAttrib("\\?\" & $sFile), "R", 2) Then Return 3 ; Read-Only Flag set Local $hFile = _WinAPI_CreateFileEx("\\?\" & $sFile, $OPEN_EXISTING, $GENERIC_READ + $GENERIC_WRITE, $FILE_SHARE_READ + $FILE_SHARE_WRITE + $FILE_SHARE_DELETE, $FILE_FLAG_BACKUP_SEMANTICS) ; Local $iReturn = $hFile _WinAPI_CloseHandle($hFile) If ($iReturn = 0) Then Return 2 ; File not accessible, UAC issue? Return 1 ; Success EndFunc ;==>_File_Is_Accessible Func _TakeOwnership($sFile, $iUserName = "Everyone", $sRecurse = 1) If ($iUserName = Default) Or (StringStripWS($iUserName, 8) = '') Then $iUserName = "Everyone" If ($sRecurse = Default) Or ($sRecurse = True) Or ($sRecurse > 0) Then $sRecurse = 1 Else $sRecurse = 0 EndIf Local $osNotIsEnglish = True Switch @OSLang Case "0009", "0409", "0809", "0C09", "1009", "1409", "1809", "1C09", "2009", "2409", "2809", "2C09", "3009", "3409", "3C09", "4009", "4409", "4809", "4C09" $osNotIsEnglish = False Case "3809", "5009", "5409", "5809", "5C09", "6009", "6409" ; new $osNotIsEnglish = False EndSwitch If StringInStr($iUserName, ' ') Then $iUserName = '"' & $iUserName & '"' If ($sRecurse = Default) Then $sRecurse = 1 If Not FileExists($sFile) Then Return SetError(1, 0, $sFile) If StringInStr(FileGetAttrib($sFile), 'D') <> 0 Then If $sRecurse Then RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '" /R /D Y', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /T /C /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /T /C /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /T /C /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS", 1)) Else RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '" ', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /C /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /C /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /C /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS", 0)) EndIf Else RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '"', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS")) EndIf Return $sFile EndFunc ;==>_TakeOwnership Func _URL_Split($sURL_Input, ByRef $sURL_Protocol, ByRef $sURL_Domain, ByRef $sURL_FilePATH, ByRef $sURL_FileName) Local $sURL_Protocol_Number_Pattern = '^(?s)(?i)(http|ftp|sftp|ftps|https|file)://(.*?/|.*$)(.*/){0,}(.*)$' Local $sURL_Pattern = "^(?i)(?:(?:[a-z]+):\/\/)?" & "(?:(?:(?:[^@:]+))" & "(?::(?:[^@]+))?@)?" & "([^\/:]+)" & "(?::(?:\d+))?" & "(?:\/(?:[^?]+)?)?" & "(?:\?\N+)?" Local $aURL_Pattern = StringRegExp($sURL_Input, $sURL_Protocol_Number_Pattern, 2) If Not IsArray($aURL_Pattern) Or UBound($aURL_Pattern) - 1 <> 4 Then Return SetError(1, 0, 0) If StringRight($aURL_Pattern[2], 1) = '/' Then $aURL_Pattern[2] = StringTrimRight($aURL_Pattern[2], 1) $aURL_Pattern[3] = '/' & $aURL_Pattern[3] EndIf $sURL_Protocol = $aURL_Pattern[1] Local $aHost = StringRegExp($sURL_Input, $sURL_Pattern, 1) If Not @error And IsArray($aHost) Then $sURL_Domain = $aHost[0] Else $sURL_Domain = $aURL_Pattern[2] EndIf $sURL_FilePATH = $aURL_Pattern[3] $sURL_FileName = $aURL_Pattern[4] Return $aURL_Pattern EndFunc ;==>_URL_Split #cs Local $sURL_Protocol, $sURL_Protocol_Number, $sURL_Domain, $sURL_Port, $sURL_User, $sURL_Password, $sURL_FilePathName, $sURL_FilePATH, $sURL_FileName _WinHttp_SplitURL($sURL_Input, $sURL_Protocol, $sURL_Domain, $sURL_Port, $sURL_User, $sURL_Password, $sURL_FilePathName, $sURL_FilePATH, $sURL_FileName) ConsoleWrite("! URL_Input : " & $sURL_Input & @CRLF) ConsoleWrite("- Protocol : " & $sURL_Protocol & @CRLF) ConsoleWrite("- Domain : " & $sURL_Domain & @CRLF) ConsoleWrite("- Port : " & $sURL_Port & @CRLF) ConsoleWrite("- User : " & $sURL_User & @CRLF) ConsoleWrite("- Password : " & $sURL_Password & @CRLF) ConsoleWrite("- FilePathName: " & $sURL_FilePathName & @CRLF) ConsoleWrite("- FilePath : " & $sURL_FilePath & @CRLF) ConsoleWrite("- FileName : " & $sURL_FileName & @CRLF) #ce Func _WinHttp_SplitURL($sURL_Input, ByRef $sURL_Protocol, ByRef $sURL_Domain, ByRef $sURL_Port, ByRef $sURL_User, ByRef $sURL_Password, ByRef $sURL_FilePathName, ByRef $sURL_FilePATH, ByRef $sURL_FileName) If StringStripWS($sURL_Input, 8) = '' Then Return SetError(1, 0, 0) $sURL_Input = StringReplace($sURL_Input, "\", "/") If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input _URL_Split($sURL_Input, $sURL_Protocol, $sURL_Domain, $sURL_FilePATH, $sURL_FileName) StringReplace($sURL_Input, '@', '') If @extended > 1 Then Local $sUser, $aUser = _StringBetween($sURL_Input, $sURL_Protocol & "://", '@') If IsArray($aUser) Then $sUser = $aUser[0] $sURL_Input = StringReplace($sURL_Input, $sURL_Protocol & "://" & $sUser & '@', $sURL_Protocol & "://" & $sUser & '%40') EndIf EndIf Local $ORG_URL_Protocol = $sURL_Protocol, $sFake_Protocol = 'http', $iFake_Protocol = False Switch $sURL_Protocol Case 'http', 'https', 'ftp' Case Else $iFake_Protocol = True $sURL_Input = StringReplace($sURL_Input, $sURL_Protocol & "://", $sFake_Protocol & "://") EndSwitch Local $aUrl = _WinHttpCrackUrl($sURL_Input) If IsArray($aUrl) Then If $iFake_Protocol Then $sURL_Protocol = $ORG_URL_Protocol Else $sURL_Protocol = ($aUrl[0] == '' ? $sURL_Protocol : $aUrl[0]) EndIf ;$sURL_Protocol_Number = $aUrl[1] $sURL_Domain = ($aUrl[2] == '' ? $sURL_Domain : $aUrl[2]) $sURL_Port = $aUrl[3] $sURL_User = StringReplace($aUrl[4], '%40', '@') $sURL_Password = $aUrl[5] $sURL_FilePathName = ($aUrl[6] == '' ? $sURL_FilePATH & $sURL_FileName : $aUrl[6]) ;$sURL_ExtraInfo = $aUrl[7] Return $aUrl EndIf Return SetError(1, 0, "") EndFunc ;==>_WinHttp_SplitURL Func _WinHTTP_GetName_ErrorCode($nErrorCode = 0) ; By Dao Van Trong - TRONG.LIVE Switch $nErrorCode Case 12001 Return "ERROR_WINHTTP_OUT_OF_HANDLES" Case 12002 Return "ERROR_WINHTTP_TIMEOUT" Case 12004 Return "ERROR_WINHTTP_INTERNAL_ERROR" Case 12005 Return "ERROR_WINHTTP_INVALID_URL" Case 12006 Return "ERROR_WINHTTP_UNRECOGNIZED_SCHEME" Case 12007 Return "ERROR_WINHTTP_NAME_NOT_RESOLVED" Case 12009 Return "ERROR_WINHTTP_INVALID_OPTION" Case 12011 Return "ERROR_WINHTTP_OPTION_NOT_SETTABLE" Case 12012 Return "ERROR_WINHTTP_SHUTDOWN" Case 12015 Return "ERROR_WINHTTP_LOGIN_FAILURE" Case 12017 Return "ERROR_WINHTTP_OPERATION_CANCELLED" Case 12018 Return "ERROR_WINHTTP_INCORRECT_HANDLE_TYPE" Case 12019 Return "ERROR_WINHTTP_INCORRECT_HANDLE_STATE" Case 12029 Return "ERROR_WINHTTP_CANNOT_CONNECT" Case 12030 Return "ERROR_WINHTTP_CONNECTION_ERROR" Case 12032 Return "ERROR_WINHTTP_RESEND_REQUEST" Case 12044 Return "ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED" Case 12150 Return "ERROR_WINHTTP_HEADER_NOT_FOUND" Case 12152 Return "ERROR_WINHTTP_INVALID_SERVER_RESPONSE" Case 12153 Return "ERROR_WINHTTP_INVALID_HEADER" Case 12154 Return "ERROR_WINHTTP_INVALID_QUERY_REQUEST" Case 12155 Return "ERROR_WINHTTP_HEADER_ALREADY_EXISTS" Case 12156 Return "ERROR_WINHTTP_REDIRECT_FAILED" Case 12178 Return "ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR" Case 12166 Return "ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT" Case 12167 Return "ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT" Case 12176 Return "ERROR_WINHTTP_UNHANDLED_SCRIPT_TYPE" Case 12177 Return "ERROR_WINHTTP_SCRIPT_EXECUTION_ERROR" Case 12172 Return "ERROR_WINHTTP_NOT_INITIALIZED" Case 12175 Return "ERROR_WINHTTP_SECURE_FAILURE" Case 12037 Return "ERROR_WINHTTP_SECURE_CERT_DATE_INVALID" Case 12038 Return "ERROR_WINHTTP_SECURE_CERT_CN_INVALID" Case 12045 Return "ERROR_WINHTTP_SECURE_INVALID_CA" Case 12057 Return "ERROR_WINHTTP_SECURE_CERT_REV_FAILED" Case 12157 Return "ERROR_WINHTTP_SECURE_CHANNEL_ERROR" Case 12169 Return "ERROR_WINHTTP_SECURE_INVALID_CERT" Case 12170 Return "ERROR_WINHTTP_SECURE_CERT_REVOKED" Case 12179 Return "ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE" Case 12180 Return "ERROR_WINHTTP_AUTODETECTION_FAILED" Case 12181 Return "ERROR_WINHTTP_HEADER_COUNT_EXCEEDED" Case 12182 Return "ERROR_WINHTTP_HEADER_SIZE_OVERFLOW" Case 12183 Return "ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW" Case 12184 Return "ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW" Case 12185 Return "ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY" Case 12186 Return "ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY" Case 12187 Return "ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED_PROXY" Case 12188 Return "ERROR_WINHTTP_SECURE_FAILURE_PROXY" Case 12189 Return "ERROR_WINHTTP_RESERVED_189" Case 12190 Return "ERROR_WINHTTP_HTTP_PROTOCOL_MISMATCH" Case 12191 Return "ERROR_WINHTTP_GLOBAL_CALLBACK_FAILED" Case 12192 Return "ERROR_WINHTTP_FEATURE_DISABLED" Return "WINHTTP_ERROR_LAST" Case Else Return SetError(1, 0, "") EndSwitch EndFunc ;==>_WinHTTP_GetName_ErrorCode Func _WinInet_GetName_ErrorCode($nErrorCode = 0) ; By Dao Van Trong - TRONG.LIVE Switch $nErrorCode Case 12000 Return "INTERNET_ERROR_BASE" Case 12001 Return "ERROR_INTERNET_OUT_OF_HANDLES" Case 12002 Return "ERROR_INTERNET_TIMEOUT" Case 12003 Return "ERROR_INTERNET_EXTENDED_ERROR" Case 12004 Return "ERROR_INTERNET_INTERNAL_ERROR" Case 12005 Return "ERROR_INTERNET_INVALID_URL" Case 12006 Return "ERROR_INTERNET_UNRECOGNIZED_SCHEME" Case 12007 Return "ERROR_INTERNET_NAME_NOT_RESOLVED" Case 12008 Return "ERROR_INTERNET_PROTOCOL_NOT_FOUND" Case 12009 Return "ERROR_INTERNET_INVALID_OPTION" Case 12010 Return "ERROR_INTERNET_BAD_OPTION_LENGTH" Case 12011 Return "ERROR_INTERNET_OPTION_NOT_SETTABLE" Case 12012 Return "ERROR_INTERNET_SHUTDOWN" Case 12013 Return "ERROR_INTERNET_INCORRECT_USER_NAME" Case 12014 Return "ERROR_INTERNET_INCORRECT_PASSWORD" Case 12015 Return "ERROR_INTERNET_LOGIN_FAILURE" Case 12016 Return "ERROR_INTERNET_INVALID_OPERATION" Case 12017 Return "ERROR_INTERNET_OPERATION_CANCELLED" Case 12018 Return "ERROR_INTERNET_INCORRECT_HANDLE_TYPE" Case 12019 Return "ERROR_INTERNET_INCORRECT_HANDLE_STATE" Case 12020 Return "ERROR_INTERNET_NOT_PROXY_REQUEST" Case 12021 Return "ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND" Case 12022 Return "ERROR_INTERNET_BAD_REGISTRY_PARAMETER" Case 12023 Return "ERROR_INTERNET_NO_DIRECT_ACCESS" Case 12024 Return "ERROR_INTERNET_NO_CONTEXT" Case 12025 Return "ERROR_INTERNET_NO_CALLBACK" Case 12026 Return "ERROR_INTERNET_REQUEST_PENDING" Case 12027 Return "ERROR_INTERNET_INCORRECT_FORMAT" Case 12028 Return "ERROR_INTERNET_ITEM_NOT_FOUND" Case 12029 Return "ERROR_INTERNET_CANNOT_CONNECT" Case 12030 Return "ERROR_INTERNET_CONNECTION_ABORTED" Case 12031 Return "ERROR_INTERNET_CONNECTION_RESET" Case 12032 Return "ERROR_INTERNET_FORCE_RETRY" Case 12033 Return "ERROR_INTERNET_INVALID_PROXY_REQUEST" Case 12034 Return "ERROR_INTERNET_NEED_UI" Case 12036 Return "ERROR_INTERNET_HANDLE_EXISTS" Case 12037 Return "ERROR_INTERNET_SEC_CERT_DATE_INVALID" Case 12038 Return "ERROR_INTERNET_SEC_CERT_CN_INVALID" Case 12039 Return "ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR" Case 12040 Return "ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR" Case 12041 Return "ERROR_INTERNET_MIXED_SECURITY" Case 12042 Return "ERROR_INTERNET_CHG_POST_IS_NON_SECURE" Case 12043 Return "ERROR_INTERNET_POST_IS_NON_SECURE" Case 12044 Return "ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED" Case 12045 Return "ERROR_INTERNET_INVALID_CA" Case 12046 Return "ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP" Case 12047 Return "ERROR_INTERNET_ASYNC_THREAD_FAILED" Case 12048 Return "ERROR_INTERNET_REDIRECT_SCHEME_CHANGE" Case 12049 Return "ERROR_INTERNET_DIALOG_PENDING" Case 12050 Return "ERROR_INTERNET_RETRY_DIALOG" Case 12052 Return "ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR" Case 12053 Return "ERROR_INTERNET_INSERT_CDROM" Case 12054 Return "ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED" Case 12055 Return "ERROR_INTERNET_SEC_CERT_ERRORS" Case 12056 Return "ERROR_INTERNET_SEC_CERT_NO_REV" Case 12057 Return "ERROR_INTERNET_SEC_CERT_REV_FAILED" Case 12060 Return "ERROR_HTTP_HSTS_REDIRECT_REQUIRED" Case 12062 Return "ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE" Case 12110 Return "ERROR_FTP_TRANSFER_IN_PROGRESS" Case 12111 Return "ERROR_FTP_DROPPED" Case 12112 Return "ERROR_FTP_NO_PASSIVE_MODE" Case 12130 Return "ERROR_GOPHER_PROTOCOL_ERROR" Case 12131 Return "ERROR_GOPHER_NOT_FILE" Case 12132 Return "ERROR_GOPHER_DATA_ERROR" Case 12133 Return "ERROR_GOPHER_END_OF_DATA" Case 12134 Return "ERROR_GOPHER_INVALID_LOCATOR" Case 12135 Return "ERROR_GOPHER_INCORRECT_LOCATOR_TYPE" Case 12136 Return "ERROR_GOPHER_NOT_GOPHER_PLUS" Case 12137 Return "ERROR_GOPHER_ATTRIBUTE_NOT_FOUND" Case 12138 Return "ERROR_GOPHER_UNKNOWN_LOCATOR" Case 12150 Return "ERROR_HTTP_HEADER_NOT_FOUND" Case 12151 Return "ERROR_HTTP_DOWNLEVEL_SERVER" Case 12152 Return "ERROR_HTTP_INVALID_SERVER_RESPONSE" Case 12153 Return "ERROR_HTTP_INVALID_HEADER" Case 12154 Return "ERROR_HTTP_INVALID_QUERY_REQUEST" Case 12155 Return "ERROR_HTTP_HEADER_ALREADY_EXISTS" Case 12156 Return "ERROR_HTTP_REDIRECT_FAILED" Case 12160 Return "ERROR_HTTP_NOT_REDIRECTED" Case 12161 Return "ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION" Case 12162 Return "ERROR_HTTP_COOKIE_DECLINED" Case 12168 Return "ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION" Case 12157 Return "ERROR_INTERNET_SECURITY_CHANNEL_ERROR" Case 12158 Return "ERROR_INTERNET_UNABLE_TO_CACHE_FILE" Case 12159 Return "ERROR_INTERNET_TCPIP_NOT_INSTALLED" Case 12163 Return "ERROR_INTERNET_DISCONNECTED" Return "ERROR_INTERNET_OFFLINE" Case 12164 Return "ERROR_INTERNET_SERVER_UNREACHABLE" Case 12165 Return "ERROR_INTERNET_PROXY_SERVER_UNREACHABLE" Case 12166 Return "ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT" Case 12167 Return "ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT" Case 12169 Return "ERROR_INTERNET_SEC_INVALID_CERT" Case 12170 Return "ERROR_INTERNET_SEC_CERT_REVOKED" Case 12171 Return "ERROR_INTERNET_FAILED_DUETOSECURITYCHECK" Case 12172 Return "ERROR_INTERNET_NOT_INITIALIZED" Case 12173 Return "ERROR_INTERNET_NEED_MSN_SSPI_PKG" Case 12174 Return "ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY" Case 12175 Return "ERROR_INTERNET_DECODING_FAILED" Case 12187 Return "ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED_PROXY" Case 12188 Return "ERROR_INTERNET_SECURE_FAILURE_PROXY" Case 12190 Return "ERROR_INTERNET_HTTP_PROTOCOL_MISMATCH" Case 12191 Return "ERROR_INTERNET_GLOBAL_CALLBACK_FAILED" Case 12192 Return "ERROR_INTERNET_FEATURE_DISABLED" Return "INTERNET_ERROR_LAST" Case 12051 Return "ERROR_INTERNET_NO_NEW_CONTAINERS" Case 12058 Return "ERROR_INTERNET_SOURCE_PORT_IN_USE" Case 12059 Return "ERROR_INTERNET_INSECURE_FALLBACK_REQUIRED" Case 12061 Return "ERROR_INTERNET_PROXY_ALERT" Case 12080 Return "ERROR_INTERNET_NO_CM_CONNECTION" Case 12147 Return "ERROR_HTTP_PUSH_STATUS_CODE_NOT_SUPPORTED" Case 12148 Return "ERROR_HTTP_PUSH_RETRY_NOT_SUPPORTED" Case 12149 Return "ERROR_HTTP_PUSH_ENABLE_FAILED" Case 12189 Return "ERROR_INTERNET_DISALLOW_INPRIVATE" Case 12900 Return "INTERNET_INTERNAL_ERROR_BASE" Case 12901 Return "ERROR_INTERNET_INTERNAL_SOCKET_ERROR" Case 12902 Return "ERROR_INTERNET_CONNECTION_AVAILABLE" Case 12903 Return "ERROR_INTERNET_NO_KNOWN_SERVERS" Case 12904 Return "ERROR_INTERNET_PING_FAILED" Case 12905 Return "ERROR_INTERNET_NO_PING_SUPPORT" Case 12906 Return "ERROR_INTERNET_CACHE_SUCCESS" Case 12907 Return "ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION_EX" Case Else Return SetError(1, 0, "") EndSwitch EndFunc ;==>_WinInet_GetName_ErrorCode If you do not have a WinHTTP UDF ("WinHttp.au3"), download it here: https://github.com/dragana-r/autoit-winhttp Standalone code: Global $__g_hWinInet_FTP = -1, $__g_hCallback_FTP, $__g_bCallback_FTP = False Global Const $STR_REGEXPARRAYGLOBALMATCH = 3, $STR_ENDISSTART = 0, $STR_ENDNOTSTART = 1, $FO_OVERWRITE = 2, $FO_BINARY = 16, $OPEN_EXISTING = 3, $FILE_SHARE_READ = 0x00000001, $FILE_SHARE_WRITE = 0x00000002, $FILE_SHARE_DELETE = 0x00000004, $GENERIC_WRITE = 0x40000000, $GENERIC_READ = 0x80000000, $INTERNET_OPEN_TYPE_DIRECT = 1, $FTP_TRANSFER_TYPE_UNKNOWN = 0, $FTP_TRANSFER_TYPE_BINARY = 2, $INTERNET_FLAG_DEFAULT = 0, $INTERNET_FLAG_PASSIVE = 0x08000000, $INTERNET_FLAG_TRANSFER_BINARY = 2, $INTERNET_SERVICE_FTP = 1, $INTERNET_FLAG_NO_CACHE_WRITE = 0x04000000, $INET_DOWNLOADCOMPLETE = 2, $INET_DOWNLOADSUCCESS = 3, $INTERNET_DEFAULT_PORT = 0, $ICU_ESCAPE = 0x80000000, $FILE_FLAG_BACKUP_SEMANTICS = 0x02000000, $WINHTTP_FLAG_ASYNC = 0x10000000, $WINHTTP_FLAG_ESCAPE_DISABLE = 0x00000040, $WINHTTP_FLAG_SECURE = 0x00800000, $WINHTTP_ACCESS_TYPE_NO_PROXY = 1, $WINHTTP_NO_PROXY_NAME = "", $WINHTTP_NO_PROXY_BYPASS = "", $WINHTTP_NO_REFERER = "", $WINHTTP_DEFAULT_ACCEPT_TYPES = 0, $WINHTTP_NO_ADDITIONAL_HEADERS = "", $WINHTTP_NO_REQUEST_DATA = "", $WINHTTP_HEADER_NAME_BY_INDEX = "", $WINHTTP_NO_HEADER_INDEX = 0, $WINHTTP_OPTION_CALLBACK = 1, $WINHTTP_OPTION_RESOLVE_TIMEOUT = 2, $WINHTTP_OPTION_CONNECT_TIMEOUT = 3, $WINHTTP_OPTION_CONNECT_RETRIES = 4, $WINHTTP_OPTION_SEND_TIMEOUT = 5, $WINHTTP_OPTION_RECEIVE_TIMEOUT = 6, $WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT = 7, $WINHTTP_OPTION_HANDLE_TYPE = 9, $WINHTTP_OPTION_READ_BUFFER_SIZE = 12, $WINHTTP_OPTION_WRITE_BUFFER_SIZE = 13, $WINHTTP_OPTION_PARENT_HANDLE = 21, $WINHTTP_OPTION_EXTENDED_ERROR = 24, $WINHTTP_OPTION_SECURITY_FLAGS = 31, $WINHTTP_OPTION_URL = 34, $WINHTTP_OPTION_SECURITY_KEY_BITNESS = 36, $WINHTTP_OPTION_PROXY = 38, $WINHTTP_OPTION_USER_AGENT = 41, $WINHTTP_OPTION_CONTEXT_VALUE = 45, $WINHTTP_OPTION_CLIENT_CERT_CONTEXT = 47, $WINHTTP_OPTION_REQUEST_PRIORITY = 58, $WINHTTP_OPTION_HTTP_VERSION = 59, $WINHTTP_OPTION_DISABLE_FEATURE = 63, $WINHTTP_OPTION_CODEPAGE = 68, $WINHTTP_OPTION_MAX_CONNS_PER_SERVER = 73, $WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER = 74, $WINHTTP_OPTION_AUTOLOGON_POLICY = 77, $WINHTTP_OPTION_SERVER_CERT_CONTEXT = 78, $WINHTTP_OPTION_ENABLE_FEATURE = 79, $WINHTTP_OPTION_WORKER_THREAD_COUNT = 80, $WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT = 81, $WINHTTP_OPTION_PASSPORT_COBRANDING_URL = 82, $WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH = 83, $WINHTTP_OPTION_SECURE_PROTOCOLS = 84, $WINHTTP_OPTION_ENABLETRACING = 85, $WINHTTP_OPTION_PASSPORT_SIGN_OUT = 86, $WINHTTP_OPTION_REDIRECT_POLICY = 88, $WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89, $WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE = 90, $WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE = 91, $WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE = 92, $WINHTTP_OPTION_CONNECTION_INFO = 93, $WINHTTP_OPTION_SPN = 96, $WINHTTP_OPTION_GLOBAL_PROXY_CREDS = 97, $WINHTTP_OPTION_GLOBAL_SERVER_CREDS = 98, $WINHTTP_OPTION_REJECT_USERPWD_IN_URL = 100, $WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101, $WINHTTP_OPTION_UNSAFE_HEADER_PARSING = 110, $WINHTTP_OPTION_DECOMPRESSION = 118, $WINHTTP_OPTION_USERNAME = 0x1000, $WINHTTP_OPTION_PASSWORD = 0x1001, $WINHTTP_OPTION_PROXY_USERNAME = 0x1002, $WINHTTP_OPTION_PROXY_PASSWORD = 0x1003, $WINHTTP_DECOMPRESSION_FLAG_ALL = 0x00000003, $WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0, $WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW = 1, $WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH = 2, $WINHTTP_ENABLE_PASSPORT_AUTH = 0x10000000, $HTTP_STATUS_DENIED = 401, $HTTP_STATUS_PROXY_AUTH_REQ = 407, $SECURITY_FLAG_IGNORE_UNKNOWN_CA = 0x00000100, $SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000, $SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000, $SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE = 0x00000200, $WINHTTP_QUERY_CONTENT_TYPE = 1, $WINHTTP_QUERY_STATUS_CODE = 19, $WINHTTP_QUERY_RAW_HEADERS_CRLF = 22, $WINHTTP_AUTH_SCHEME_BASIC = 0x00000001, $WINHTTP_AUTH_SCHEME_PASSPORT = 0x00000004, $WINHTTP_AUTH_TARGET_SERVER = 0x00000000 Global Const $hWINHTTPDLL__WINHTTP = DllOpen("winhttp.dll") DllOpen("winhttp.dll") ;Opt("MustDeclareVars", 1) Opt("TrayAutoPause", 0) If StringInStr(@OSArch, "64") And (Not @AutoItX64) Then _WinAPI_Wow64EnableWow64FsRedirection(0) ; #CONSTANTS# =================================================================================================================== Global Const $ViewLogConsole = 1, $bGetFieSize = 1 Global Const $OPTION_ENABLE_REDIRECTS = 6, $OPTION_USER_AGENT = 0 Global $obError = False, $oErrorHandler = ObjEvent("AutoIt.Error", "__Skip_OBJ_Error") Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") Global $sUSER_AGENT = __WinHttpUA(), $TempDir = @TempDir If Not _Directory_Is_Accessible($TempDir) Then $TempDir = @LocalAppDataDir & "\Temp" If Not _Directory_Is_Accessible($TempDir) Then $TempDir = @ScriptDir EndIf ; =========================================================================================== ; Example Global $ftpUserName = "ftpuser@files.trong.live" Global $ftpPassword = "files.trong.live" Global $httpUserName = 'trong' Global $httpPassword = 'autoit' _Download('https://files.trong.live/test.jpg', @ScriptDir & "\testA.jpg") _Download('https://files.trong.live/prv/test.jpg', @ScriptDir & "\testA.jpg", $httpUserName, $httpPassword) _FTP_Download('ftp://files.trong.live/prv/test.jpg', @ScriptDir & "\testB.jpg", $ftpUserName, $ftpPassword) _Download('https://go.microsoft.com/fwlink/?LinkID=2093505', @ScriptDir & "\Microsoft_Edge_Ent_X86.msi") _WinHttp_Download('http://go.microsoft.com/fwlink/?LinkID=2093437', @ScriptDir & "\Microsoft_Edge_Ent_X64.msi") ; #CURRENT# ===================================================================================================================== ; _Download() ; _FTP_Download() ; _WinHttp_Download() ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Author... ...........: Dao Van Trong - TRONG.LIVE ; =========================================================================================== Func _Download($sURL_Input, $sLocalPathSAVE, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) $sURL_Input = StringReplace($sURL_Input, "\", "/") If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If ($dProtocol = "ftp" Or $dProtocol = "sftp" Or $dProtocol = "ftps") Then Local $fDL = _FTP_Download($sURL_Input, $sLocalPathSAVE, $dUserName, $dPassword) Return SetError(@error, @extended, $fDL) EndIf If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf If (Not ($dUserName == '')) Then ;$dUserName = StringReplace($dUserName, '@', '%40') If ($dProtocol == 'https' And $dPort <> 443) Or ($dProtocol == 'http' And $dPort <> 80) Then $sURL_Input = $dProtocol & "://" & $dUserName & ":" & $dPassword & "@" & $dDomain & ":" & $dPort & $dURLFilePathName Else $sURL_Input = $dProtocol & "://" & $dUserName & ":" & $dPassword & "@" & $dDomain & $dURLFilePathName EndIf EndIf _LogDebug("- InetGet Download: " & $sURL_Input & " -> " & $sLocalPathSAVE & @CRLF) Local $dlTempFilePath While 1 $dlTempFilePath = $TempDir & "\~download-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "-" & Random(88888888, 99999999, 1) & ".tmp" If (Not FileExists($dlTempFilePath)) Then ExitLoop WEnd $dUserName = StringReplace($dUserName, '%40', '@') Local $sURL_Rediect Local $urlStatus = __URL_Check($sURL_Input, $sURL_Rediect, $dUserName, $dPassword) If @error Then _LogDebug("! /!\ Test connect Error ! " & @CRLF) Return 0 EndIf If ($sURL_Rediect == "") Then Else $sURL_Input = $sURL_Rediect EndIf HttpSetUserAgent($sUSER_AGENT) If $bGetFieSize Then _LogDebug("+ Get file size.... ") $dFileSize = InetGetSize($sURL_Input) If @error Then _LogDebug(" ERROR !" & @CRLF) Else _LogDebug(" OK -> " & _Byte_GetDisplay($dFileSize) & " " & @CRLF) EndIf EndIf _LogDebug("+ Downloading.... ") Local $hDownload = InetGet($sURL_Input, $dlTempFilePath, 1 + 2 + 16, 1) Local $Percentage = 0, $Old_Percentage = 0, $TotalToDownload = 0, $BytesDownloaded = 0, $DownloadedSoFar = 0, $pCheck = 0 Do Sleep(100) If $dFileSize > 0 Then ; Get number of bytes read for current file $BytesDownloaded = InetGetInfo($hDownload, 0) ; Add this to the cumulative total $DownloadedSoFar = $TotalToDownload + $BytesDownloaded ; Calculate the current file percentage $Percentage = Floor(($BytesDownloaded / $dFileSize) * 100) ; Only update the current file percent label if it has changed to avoid flickering If ($Percentage - $Old_Percentage) > 4 Then _LogDebug($Percentage & "% ") $Old_Percentage = $Percentage EndIf EndIf Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. ;Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) ;Local $iFileSize = FileGetSize($dlTempFilePath) ;ConsoleWrite("- Downloaded: " & $iBytesSize & " KB/s " & @CRLF) ;ConsoleWrite("- File Size: " & $iFileSize & " KB/s " & @CRLF) Local $aDownloadData = InetGetInfo($hDownload) InetClose($hDownload) If ($aDownloadData[$INET_DOWNLOADSUCCESS] And FileExists($dlTempFilePath)) Then _LogDebug("- DONE !" & @CRLF) __File_SAVE($dlTempFilePath, $sLocalPathSAVE) If FileExists($sLocalPathSAVE) Then _LogDebug("+ Save file to: " & $sLocalPathSAVE & " OK !" & @CRLF) Else _LogDebug("! Save file to: " & $sLocalPathSAVE & " ERROR !" & @CRLF) EndIf Else _LogDebug(" ERROR " & @CRLF) _LogDebug("- Try Download again with WinHttp !" & @CRLF) Return _WinHttp_Download($sURL_Input, $sLocalPathSAVE) EndIf EndFunc ;==>_Download Func _WinHttp_Download($sURL_Input, $sLocalPathSAVE, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If ($dProtocol = "ftp" Or $dProtocol = "sftp" Or $dProtocol = "ftps") Then Local $fDL = _FTP_Download($sURL_Input, $sLocalPathSAVE, $dUserName, $dPassword) Return SetError(@error, @extended, $fDL) EndIf If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf _LogDebug("+ WinHttp Download: " & $sURL_Input & " -> " & $sLocalPathSAVE & @CRLF) Local $sURL_Rediect Local $urlStatus = __URL_Check($sURL_Input, $sURL_Rediect, $dUserName, $dPassword) If @error Then _LogDebug("! /!\ Test connect Error ! " & @CRLF) Return 0 EndIf If ($sURL_Rediect == "") Then Else $sURL_Input = $sURL_Rediect EndIf Local $dlTempFilePath While 1 $dlTempFilePath = $TempDir & "\~download-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "-" & Random(88888888, 99999999, 1) & ".tmp" If (Not FileExists($dlTempFilePath)) Then ExitLoop WEnd ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Set User-Agent string _WinHttpSetOption($hOpen, $WINHTTP_OPTION_USER_AGENT, $sUSER_AGENT) ; Get connection handle _LogDebug("- WinHttp Connecting ...") Local $hConnect = _WinHttpConnect($hOpen, $dDomain) If @error Then _LogDebug(" ERROR " & @error & @CRLF) Return SetError(1, 0, 0) EndIf _LogDebug(" OK" & @CRLF & "- WinHttp Downloading ...") ; SimpleSSL-request it... Local $vReturned If (($dProtocol = "https") Or ($dPort = 443)) Then $vReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $dURLFilePathName, $dProtocol & "://" & $dDomain, $WINHTTP_NO_REQUEST_DATA, $WINHTTP_NO_ADDITIONAL_HEADERS, False, 2, $dUserName, $dPassword) Else $vReturned = _WinHttpSimpleRequest($hConnect, "GET", $dURLFilePathName, $dProtocol & "://" & $dDomain, $WINHTTP_NO_REQUEST_DATA, $WINHTTP_NO_ADDITIONAL_HEADERS, False, 2, $dUserName, $dPassword) EndIf If @error Then _LogDebug("! Request ERROR " & @error & @CRLF) Return SetError(2, 0, 0) EndIf _LogDebug(" OK" & @CRLF & "- Saving to file ...") ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If FileExists($sLocalPathSAVE) Then _DelIt($sLocalPathSAVE, 1) Local $iDirFile = _Path_Split($sLocalPathSAVE, 6) If Not FileExists($iDirFile) Then DirCreate($iDirFile) Local $DataLen = BinaryLen($vReturned) Local $hFile = FileOpen($sLocalPathSAVE, 2 + 8 + 16) FileWrite($hFile, $vReturned) FileClose($hFile) If FileExists($sLocalPathSAVE) Then _LogDebug(" OK (Size: " & _Byte_GetDisplay($DataLen) & ") file: " & $sLocalPathSAVE & @CRLF) Return 1 Else _LogDebug(" ERROR (Size: " & _Byte_GetDisplay($DataLen) & ") file: " & $sLocalPathSAVE & @CRLF) Return SetError(1, 0, 0) EndIf EndFunc ;==>_WinHttp_Download Func _FTP_Download($sURL_Input, $sLocalPathSAVE, $dUserName = "anonymous", $dPassword = "") _LogDebug("+ FTP Download: " & $sURL_Input & " -> " & $sLocalPathSAVE & @CRLF) If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'ftp://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) #cs ConsoleWrite("- Protocol : " & $dProtocol & @CRLF) ConsoleWrite("- Domain : " & $dDomain & @CRLF) ConsoleWrite("- Port : " & $dPort & @CRLF) ConsoleWrite("- User : " & $dUser & @CRLF) ConsoleWrite("- Password : " & $dPass & @CRLF) ConsoleWrite("- FilePathName: " & $dURLFilePathName & @CRLF) ConsoleWrite("- FilePath : " & $dURLFilePath & @CRLF) ConsoleWrite("- FileName : " &$dURLFileName & @CRLF) #ce If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "")) Then $dUserName = "anonymous" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf Local $Err, $sFTP_Message, $iReturn = 0, $iError = 0 Local $dlTempFilePath = $TempDir & "\~download.tmp" While 1 $dlTempFilePath = $TempDir & "\~download-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "-" & Random(88888888, 99999999, 1) & ".tmp" If (Not FileExists($dlTempFilePath)) Then ExitLoop WEnd If $bGetFieSize Then _LogDebug("- FTP Getting the file size... " & @CRLF) $dFileSize = _Byte_GetDisplay(__FTP_FileGetSize($sURL_Input, $dUserName, $dPassword)) EndIf ;_LogDebug("-Protocol: " & $dProtocol & @CRLF) ;_LogDebug("-Server: " & $dDomain & @CRLF) ;_LogDebug("-User: '" & $dUserName & "'" & @CRLF) ;_LogDebug("-Password: '" & $dPassword & "'" & @CRLF) ;_LogDebug("-RemoteFile: " & $dURLFilePathName & @CRLF) If $dFileSize > 0 Then _LogDebug("- File Size: " & $dFileSize & @CRLF) Else _LogDebug("! An error occurred, Getting the file size failed!" & @CRLF) EndIf _LogDebug("- FTP Getting the file ... " & @CRLF) Local $hOpen = _FTP_Open('FTP_Client', $INTERNET_OPEN_TYPE_DIRECT) If @error Then Return SetError(1, 0, 0) Local $hFTPSession = _FTP_Connect($hOpen, $dDomain, $dUserName, $dPassword) If @error Then Local $WinHTTP_Error_Return = @extended Local $WinHTTP_Error_Name = _WinHTTP_GetName_ErrorCode($WinHTTP_Error_Return) _LogDebug('! _FTP_Connect Error: ' & @error & " - Extended: " & $WinHTTP_Error_Return & @CRLF) _LogDebug('! WinHTTP Error: ' & $WinHTTP_Error_Name & @CRLF) If ($WinHTTP_Error_Return = 12029) Then _LogDebug('! Error: A connection with the server could not be established' & @CRLF) If ($WinHTTP_Error_Return = 12014) Then _LogDebug('! Error: The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect.' & @CRLF) Return SetError(2, $WinHTTP_Error_Return, 0) EndIf If $bGetFieSize Then _LogDebug("- Downloading " & $dURLFilePathName & " (" & $dFileSize & ") " & " ..." & @CRLF) Else _LogDebug("- Downloading " & $dURLFilePathName & " ...") EndIf Local $fuFunctionToCall = __FTPGetFile_UpdateProgress Local $iFDL = _FTP_ProgressDownload($hFTPSession, $dlTempFilePath, $dURLFilePathName, $fuFunctionToCall) Local $iErr, $sFTP_Message If (Not FileExists($dlTempFilePath)) Then _FTP_GetLastResponseInfo($iErr, $sFTP_Message) _LogDebug('! ERROR ! Code: [' & $Err & '] FTP_Message: [' & @CRLF & $sFTP_Message & "]" & @CRLF) _FTP_Close($hFTPSession) _FTP_Close($hOpen) $hOpen = _FTP_Open('FTP_Client', $INTERNET_OPEN_TYPE_DIRECT) $hFTPSession = _FTP_Connect($hOpen, $dDomain, $dUserName, $dPassword) If @error Then Local $WinHTTP_Error_Return = @extended Local $WinHTTP_Error_Name = _WinHTTP_GetName_ErrorCode($WinHTTP_Error_Return) _LogDebug('! _FTP_Connect Error: ' & @error & " - Extended: " & $WinHTTP_Error_Return & @CRLF) _LogDebug('! WinHTTP Error: ' & $WinHTTP_Error_Name & @CRLF) If ($WinHTTP_Error_Return = 12029) Then _LogDebug('! Error: A connection with the server could not be established' & @CRLF) If ($WinHTTP_Error_Return = 12014) Then _LogDebug('! Error: The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect.' & @CRLF) Return SetError(2, $WinHTTP_Error_Return, 0) EndIf $iFDL = _FTP_FileGet($hFTPSession, $dURLFilePathName, $dlTempFilePath, False, Default, $FTP_TRANSFER_TYPE_BINARY) If (Not FileExists($dlTempFilePath)) Then _FTP_GetLastResponseInfo($iErr, $sFTP_Message) _LogDebug('! ERROR ! Code: [' & $Err & '] FTP_Message: [' & @CRLF & $sFTP_Message & "]" & @CRLF) _FTP_Close($hFTPSession) _FTP_Close($hOpen) Return SetError(3, 0, 0) Else _LogDebug('+ OK !' & @CRLF) EndIf Else _LogDebug('+ OK !' & @CRLF) EndIf _FTP_Close($hFTPSession) _FTP_Close($hOpen) __File_SAVE($dlTempFilePath, $sLocalPathSAVE) If FileExists($sLocalPathSAVE) Then _LogDebug("+ Save file to: " & $sLocalPathSAVE & " OK !" & @CRLF) Return SetError(0, 0, 1) Else _LogDebug("! Save file to: " & $sLocalPathSAVE & " ERROR !" & @CRLF) Return SetError(4, 0, 0) EndIf EndFunc ;==>_FTP_Download Func __FTPGetFile_UpdateProgress($iPercent) _LogDebug(" " & Int($iPercent) & "%" & ' ') ;If _IsPressed("77") Then Return 0 ; Abort on F8 Return 1 ; 1 to continue Download EndFunc ;==>__FTPGetFile_UpdateProgress Func __FTP_FileGetSize($sURL_Input, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'ftp://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "")) Then $dUserName = "anonymous" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf Local $hOpen = _FTP_Open('FTP_Client') If @error Then Return SetError(1, 0, "") Local $hConn = _FTP_Connect($hOpen, $dDomain, $dUserName, $dPassword) If @error Then Local $WinHTTP_Error_Return = @extended Local $WinHTTP_Error_Name = _WinHTTP_GetName_ErrorCode($WinHTTP_Error_Return) _LogDebug('! _FTP_Connect Error: ' & @error & " - Extended: " & $WinHTTP_Error_Return & @CRLF) _LogDebug('! WinHTTP Error: ' & $WinHTTP_Error_Name & @CRLF) If ($WinHTTP_Error_Return = 12029) Then _LogDebug('! Error: A connection with the server could not be established' & @CRLF) If ($WinHTTP_Error_Return = 12014) Then _LogDebug('! Error: The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect.' & @CRLF) Return SetError(2, $WinHTTP_Error_Return, 0) EndIf Local $iFileSize = _FTP_FileGetSize($hConn, $dURLFilePathName) If @error Then Return SetError(3, 0, "") ;ConsoleWrite('$sFilenameNext1 = ' & $dFileName & ' size = ' & $iFileSize & ' -> Error code: ' & @error & ' extended: ' & @extended & @CRLF) Local $iErr, $sMessage Local $iFtpr = _FTP_GetLastResponseInfo($iErr, $sMessage) ; no error ;ConsoleWrite('$sMessage = ' & $sMessage & ' err = ' & $iErr & ' -> Error code: ' & @error & ' extended: ' & @extended & @CRLF) Local $iFtpc = _FTP_Close($hConn) Local $iFtpo = _FTP_Close($hOpen) Return $iFileSize EndFunc ;==>__FTP_FileGetSize Func __File_SAVE($dlTempFilePath, $sLocalPathSAVE) If Not FileExists($dlTempFilePath) Then _LogDebug("! Source path is not File Exists: " & $dlTempFilePath & @CRLF) Return SetError(1, 0, -1) EndIf _LogDebug("- Move (" & FileExists($dlTempFilePath) & ") " & $dlTempFilePath & " >TO> " & $sLocalPathSAVE & " > ") If FileExists($sLocalPathSAVE) Then _DelIt($sLocalPathSAVE, 1) Local $iDirFile = _Path_Split($sLocalPathSAVE, 6) If Not FileExists($iDirFile) Then DirCreate($iDirFile) If FileMove($dlTempFilePath, $sLocalPathSAVE, 1) Then _DelIt($dlTempFilePath, 1) _LogDebug(" Move OK" & @CRLF) Return 1 Else _LogDebug(" ERROR !" & @CRLF & @CRLF) _LogDebug("- Try Copy (" & FileExists($dlTempFilePath) & ") " & $dlTempFilePath & " >TO> " & $sLocalPathSAVE & " > ") If FileCopy($dlTempFilePath, $sLocalPathSAVE, 1) Then _DelIt($dlTempFilePath, 1) _LogDebug(" OK" & @CRLF) Return 1 Else _LogDebug(" ERROR !" & @CRLF & @CRLF) Return 0 EndIf EndIf EndFunc ;==>__File_SAVE Func _Encode_URL($UnicodeURL) Local $UnicodeBinary = StringToBinary($UnicodeURL, 4) Local $UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1) Local $UnicodeBinaryLength = StringLen($UnicodeBinary2) Local $EncodedString, $UnicodeBinaryChar For $i = 1 To $UnicodeBinaryLength Step 2 $UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2) If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString('0x' & $UnicodeBinaryChar, 4)) Then $EncodedString &= BinaryToString('0x' & $UnicodeBinaryChar) Else $EncodedString &= '%' & $UnicodeBinaryChar EndIf Next Return $EncodedString EndFunc ;==>_Encode_URL Func _Decode_URL($toDecode) Local $strChar = "", $iOne, $iTwo Local $aryHex = StringSplit($toDecode, "") For $i = 1 To $aryHex[0] If $aryHex[$i] = "%" Then $i = $i + 1 $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $strChar = $strChar & Chr(Dec($iOne & $iTwo)) Else $strChar = $strChar & $aryHex[$i] EndIf Next Local $Process = StringToBinary(StringReplace($strChar, "+", " ")) Local $DecodedString = BinaryToString($Process, 4) Return $DecodedString EndFunc ;==>_Decode_URL Func __URL_Status($sURL_Input, ByRef $sURL_Rediect, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf If (Not ($dUserName == '')) Then If ($dProtocol == 'https' And $dPort <> 443) Or ($dProtocol == 'http' And $dPort <> 80) Then $sURL_Input = $dProtocol & "://" & $dDomain & ":" & $dPort & $dURLFilePathName Else $sURL_Input = $dProtocol & "://" & $dDomain & $dURLFilePathName EndIf EndIf $oHTTP.Option($OPTION_USER_AGENT) = $sUSER_AGENT $oHTTP.Option($OPTION_ENABLE_REDIRECTS) = False $oHTTP.Open("HEAD", $sURL_Input, False) If @error Then Return SetError(1, @error, -1) If (StringLen(StringStripWS($dUserName, 8)) > 1) Then $oHTTP.SetCredentials($dUserName, $dPassword, 0) $oHTTP.Send() If @error Then Return SetError(2, @error, 105) ;Error 105 (net::ERR_NAME_NOT_RESOLVED) Local $oStatus = $oHTTP.Status If @error Then Return SetError(3, @error, 118) ;Error 118 (net::ERR_CONNECTION_TIMED_OUT) If (($oStatus = 301) Or ($oStatus = 302)) Then $sURL_Rediect = $oHTTP.GetResponseHeader("Location") _LogDebug("! Redirect to URL: " & $sURL_Rediect & @CRLF) EndIf ;_LogDebug("+ GetResponseHeader: " & $oStatus & @CRLF) ;_LogDebug("- Cache-Control: " & $oHTTP.GetResponseHeader("Cache-Control") & @CRLF) ;_LogDebug("- Connection: " & $oHTTP.GetResponseHeader("Connection") & @CRLF) ;_LogDebug("- Date: " & $oHTTP.GetResponseHeader("Date") & @CRLF) ;_LogDebug("- Keep-Alive: " & $oHTTP.GetResponseHeader("Keep-Alive") & @CRLF) _LogDebug("- Content-Length: " & _Byte_GetDisplay($oHTTP.GetResponseHeader("Content-Length")) & @CRLF) ;_LogDebug("- Content-Type: " & $oHTTP.GetResponseHeader("Content-Type") & @CRLF) ;_LogDebug("- Expires: " & $oHTTP.GetResponseHeader("Expires") & @CRLF) ;_LogDebug("- Last-Modified: " & $oHTTP.GetResponseHeader("Last-Modified") & @CRLF) ;_LogDebug("- Accept-Ranges: " & $oHTTP.GetResponseHeader("Accept-Ranges") & @CRLF) ;_LogDebug("- Server: " & $oHTTP.GetResponseHeader("Server") & @CRLF) ;_LogDebug("- WWW-Authenticate: " & $oHTTP.GetResponseHeader("WWW-Authenticate") & @CRLF) ;_LogDebug($oHTTP.getAllResponseHeaders() & @CRLF) $oHTTP.Option($OPTION_ENABLE_REDIRECTS) = True Return SetError(0, 0, $oStatus) EndFunc ;==>__URL_Status Func _Check_Connect($iDomain, $iPort = 80) Opt("TCPTimeout", 3000) TCPStartup() _LogDebug("- Checking Domain: " & $iDomain & " | Port: " & $iPort & " ") Local $sIPAddress = TCPNameToIP($iDomain) _LogDebug(" -> IP Address: " & $sIPAddress) Local $iSocket = TCPConnect($sIPAddress, $iPort) If $iSocket < 1 Then _LogDebug(" -> ERROR !" & @CRLF) Return SetError(1, 0, 0) Else _LogDebug(" -> SK:" & $iSocket & " OK !" & @CRLF) Return SetError(0, 0, 1) EndIf TCPShutdown() Opt("TCPTimeout", 250) EndFunc ;==>_Check_Connect Func __URL_Check($sURL_Input, ByRef $sURL_Rediect, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) #cs ConsoleWrite("- Protocol : " & $dProtocol & @CRLF) ConsoleWrite("- Domain : " & $dDomain & @CRLF) ConsoleWrite("- Port : " & $dPort & @CRLF) ConsoleWrite("- User : " & $dUser & @CRLF) ConsoleWrite("- Password : " & $dPass & @CRLF) ConsoleWrite("- FilePathName: " & $dURLFilePathName & @CRLF) ConsoleWrite("- FilePath : " & $dURLFilePath & @CRLF) ConsoleWrite("- FileName : " &$dURLFileName & @CRLF) #ce If $dPort > 0 Then If _Check_Connect($dDomain, $dPort) = 0 Then Return SetError(1, 0, 0) Else Switch $dProtocol Case "http" If (_Check_Connect($dDomain, 80) = 0) Then Return SetError(1, 0, 0) Case "https" If (_Check_Connect($dDomain, 443) = 0) Then Return SetError(1, 0, 0) Case "ftp", "ftps" If (_Check_Connect($dDomain, 21) = 0) Then Return SetError(1, 0, 0) Case "sftp" If (_Check_Connect($dDomain, 22) = 0) Then Return SetError(1, 0, 0) EndSwitch EndIf Local $urlStatus = __URL_Status($sURL_Input, $sURL_Rediect, $dUserName, $dPassword) Switch $urlStatus Case 301, 302 If ($sURL_Rediect == "") Then Else $sURL_Input = $sURL_Rediect EndIf _LogDebug("- URL Status: " & $urlStatus & " > Connection Successful! (URL redirect to: " & $sURL_Input & ")" & @CRLF) Return SetError(0, 0, __URL_Check($sURL_Input, $sURL_Rediect, $dUserName, $dPassword)) Case 200 _LogDebug("- URL Status: " & $urlStatus & " > Connection Successful! (URL: " & $sURL_Input & ")" & @CRLF) Return SetError(0, 0, $urlStatus) Case 401, 407 _LogDebug("- URL Status: " & $urlStatus & " > Connection error! > Unauthorized (URL: " & $sURL_Input & ")" & @CRLF) Case 404 _LogDebug("- URL Status: " & $urlStatus & " > Connection Successful! > URL Not Found: " & $sURL_Input & @CRLF) Case 105 _LogDebug("- URL Status: " & $urlStatus & " > Connection error: ERR_NAME_NOT_RESOLVED > URL is Not Found: " & $sURL_Input & @CRLF) Case Else _LogDebug("- URL Status: " & $urlStatus & " > Connection error! > URL: " & $sURL_Input & @CRLF) EndSwitch Return SetError(1, 0, $urlStatus) EndFunc ;==>__URL_Check Func _Byte_GetDisplay($iSize, $iPlaces = 4) Local $aBytes[7] = [' Bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB'] For $i = 6 To 1 Step -1 If $iSize >= 1024 ^ $i Then Return Round($iSize / 1024 ^ $i, $iPlaces) & $aBytes[$i] EndIf Next Return $iSize & ' Bytes' EndFunc ;==>_Byte_GetDisplay Func _Convert_Size($inputSize, $inputUnit = 0, $outputPlaces = 2, $outputString = True, $inputBits = False, $outputBits = False, $outputUnit = -4) Local $unitNames[9] = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"] Local $Bytes = $inputSize * 1024 ^ $inputUnit Local $b = "B" If $inputBits Then $Bytes /= 8 If $outputBits Then $Bytes *= 8 $b = "b" EndIf If $outputUnit < 0 Then Local $outputMax = Abs($outputUnit) $outputUnit = Int(Log($Bytes) / Log(1024)) If $outputUnit > $outputMax Then $outputUnit = $outputMax EndIf If $outputString Then Return String(Round($Bytes / 1024 ^ $outputUnit, $outputPlaces)) & " " & $unitNames[$outputUnit] & $b Else Return Round($Bytes / 1024 ^ $outputUnit, $outputPlaces) EndIf EndFunc ;==>_Convert_Size Func _Path_Split($sFilePath, $sType = 0) Local $sDrive, $sDir, $sFileName, $sExtension, $sReturn Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1) If @error Then ReDim $aArray[5] $aArray[0] = $sFilePath EndIf $sDrive = $aArray[1] If StringLeft($aArray[2], 1) == "/" Then $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\/") Else $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\\") EndIf $aArray[2] = $sDir $sFileName = $aArray[3] $sExtension = $aArray[4] If $sType = 1 Then Return $sDrive If $sType = 2 Then Return $sDir If $sType = 3 Then Return $sFileName If $sType = 4 Then Return $sExtension If $sType = 5 Then Return $sFileName & $sExtension If $sType = 6 Then Return $sDrive & $sDir If $sType = 7 Then Return $sDrive & $sDir & $sFileName Return $aArray EndFunc ;==>_Path_Split Func _IsFile($sPath) If (Not FileExists($sPath)) Then Return SetError(-1, 0, 0) If StringInStr(FileGetAttrib($sPath), 'D') <> 0 Then Return SetError(0, 0, 0) Else Return SetError(0, 0, 1) EndIf EndFunc ;==>_IsFile Func _DelIt($sPath, $Fc = 1) If (Not FileExists($sPath)) Then Return SetError(-1, 0, 1) If _IsFile($sPath) Then Return SetError(0, 0, _DelFile($sPath, $Fc)) Else Return SetError(0, 0, _RemoveDir($sPath, $Fc)) EndIf EndFunc ;==>_DelIt Func _DelFile($sPath, $Fc = 1) If (Not _IsFile($sPath)) Then Return SetError(-1, 0, 0) Else FileSetAttrib($sPath, "-RSH") FileDelete($sPath) If $Fc Then If FileExists($sPath) Then _TakeOwnership($sPath, "Everyone", $Fc) If FileExists($sPath) Then FileDelete($sPath) If FileExists($sPath) Then RunWait(@ComSpec & ' /c Del /f /q "' & $sPath & '"', '', @SW_HIDE) EndIf If FileExists($sPath) Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndIf EndFunc ;==>_DelFile Func _RemoveDir($sPath, $Fc = 1) If _IsFile($sPath) Then Return SetError(-1, 0, 0) Else DirRemove($sPath, $Fc) If FileExists($sPath) Then _TakeOwnership($sPath, "Everyone", $Fc) DirRemove($sPath, $Fc) If FileExists($sPath) Then RunWait(@ComSpec & ' /c rmdir "' & $sPath & '" /s /q ', '', @SW_HIDE) If FileExists($sPath) Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndIf EndFunc ;==>_RemoveDir Func _GetDomainURL($sURL_Input) Local $sURL_Pattern = "^(?i)(?:(?:[a-z]+):\/\/)?" & _ ; Protocol "(?:(?:(?:[^@:]+))" & _ ; Username "(?::(?:[^@]+))?@)?" & _ ; Password "([^\/:]+)" & _ ; Host "(?::(?:\d+))?" & _ ; Port "(?:\/(?:[^?]+)?)?" & _ ; Path "(?:\?\N+)?" ; Query Local $aHost = StringRegExp($sURL_Input, $sURL_Pattern, 1) If IsArray($aHost) Then Return $aHost[0] Return "" EndFunc ;==>_GetDomainURL Func _LogDebug($iLog = "", $iLogs = "", $itype = -1) If (($itype = 0) And ($iLog = "") And ($iLogs = "")) Then Return 0 If (($itype = -1) And $ViewLogConsole) Then Return ConsoleWrite($iLog) If ($iLogs = "") Then $iLogs = $iLog If ($itype = 0) Then If $ViewLogConsole Then ConsoleWrite("- " & $iLog & @CRLF) ;If $sTextColor <> $lBkColor Then ;$sTextColor = $lBkColor ;GUICtrlSetColor($labStatus, $sTextColor) ;EndIf ;GUICtrlSetData($labStatus, $iLogs) Else If $ViewLogConsole Then ConsoleWrite("! " & $iLog & @CRLF) ;If $sTextColor <> $sTextColorError Then ;$sTextColor = $sTextColorError ;GUICtrlSetColor($labStatus, $sTextColor) ;EndIf ;GUICtrlSetData($labStatus, $iLogs) EndIf Return 1 EndFunc ;==>_LogDebug Func __Skip_OBJ_Error() $obError = True ;ConsoleWrite("! " & $obError.description & @CRLF) EndFunc ;==>__Skip_OBJ_Error Func _WinHttpURL_GetStatus($sURL_Input, $dUserName = "anonymous", $dPassword = "") If (StringStripWS($sURL_Input, 8) == '') Then Return SetError(1, 0, 0) If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input Local $dFileSize, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName _WinHttp_SplitURL($sURL_Input, $dProtocol, $dDomain, $dPort, $dUser, $dPass, $dURLFilePathName, $dURLFilePath, $dURLFileName) If (($dUserName = Default) Or (StringStripWS($dUserName, 8) == "") Or (StringLower($dUserName) == "anonymous")) Then $dUserName = "" If ((StringLower($dUserName) == "anonymous") Or ($dUserName == "") And (StringLen(StringStripWS($dUser, 8)) > 1)) Then $dUserName = $dUser If (($dPassword == "") And (StringLen($dPass) > 1)) Then $dPassword = $dPass EndIf ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, $dDomain) ; Specify the reguest Global $hRequest = _WinHttpOpenRequest($hConnect, "HEAD", $dURLFilePathName, Default, $dProtocol & "://" & $dDomain) ; Set credentials If (StringLen(StringStripWS($dUserName, 8)) > 1) Then _WinHttpSetCredentials($hRequest, $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_BASIC, $dUserName, $dPassword) ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) ; Get full header Global $sHeader = _WinHttpQueryHeaders($hRequest) ConsoleWrite($sHeader & @CRLF) ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) EndFunc ;==>_WinHttpURL_GetStatus Func _Directory_Is_Accessible($sPath, $iTouch = 0) If Not FileExists($sPath) Then DirCreate($sPath) If Not StringInStr(FileGetAttrib($sPath), "D", 2) Then Return SetError(1, 0, 0) Local $iEnum = 0, $maxEnum = 9999, $iRandom = Random(88888888, 99999999, 1) If $iTouch Then _TakeOwnership($sPath, "Everyone", 1) While FileExists($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom) $iEnum += 1 If ($iEnum > $maxEnum) Then Return SetError(2, 0, 0) WEnd Local $iSuccess = DirCreate($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom) Switch $iSuccess Case 1 $iTouch = DirRemove($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom, 1) Return SetError($iTouch < 1, 0, $iTouch) Case Else Return SetError(3, 0, 0) EndSwitch EndFunc ;==>_Directory_Is_Accessible Func _File_Is_Accessible($sFile, $iTouch = 0) ; Returns ; 1 = Success, file is writeable and deletable ; 2 = Access Denied because of lacking access rights OR because file is open by another process ; 3 = File is set "Read Only" by attribute ; 0 = File not found or Is Directory If ((Not FileExists("\\?\" & $sFile)) Or StringInStr(FileGetAttrib("\\?\" & $sFile), "D", 2)) Then Return SetError(1, 0, 0) Local $oFileAttrib = FileGetAttrib("\\?\" & $sFile) If $iTouch Then FileSetAttrib("\\?\" & $sFile, "-RHS") _TakeOwnership($sFile, "Everyone", 1) EndIf If StringInStr(FileGetAttrib("\\?\" & $sFile), "R", 2) Then Return 3 ; Read-Only Flag set Local $hFile = _WinAPI_CreateFileEx("\\?\" & $sFile, $OPEN_EXISTING, $GENERIC_READ + $GENERIC_WRITE, $FILE_SHARE_READ + $FILE_SHARE_WRITE + $FILE_SHARE_DELETE, $FILE_FLAG_BACKUP_SEMANTICS) ; Local $iReturn = $hFile _WinAPI_CloseHandle($hFile) If ($iReturn = 0) Then Return 2 ; File not accessible, UAC issue? Return 1 ; Success EndFunc ;==>_File_Is_Accessible Func _TakeOwnership($sFile, $iUserName = "Everyone", $sRecurse = 1) If ($iUserName = Default) Or (StringStripWS($iUserName, 8) = '') Then $iUserName = "Everyone" If ($sRecurse = Default) Or ($sRecurse = True) Or ($sRecurse > 0) Then $sRecurse = 1 Else $sRecurse = 0 EndIf Local $osNotIsEnglish = True Switch @OSLang Case "0009", "0409", "0809", "0C09", "1009", "1409", "1809", "1C09", "2009", "2409", "2809", "2C09", "3009", "3409", "3C09", "4009", "4409", "4809", "4C09" $osNotIsEnglish = False Case "3809", "5009", "5409", "5809", "5C09", "6009", "6409" ; new $osNotIsEnglish = False EndSwitch If StringInStr($iUserName, ' ') Then $iUserName = '"' & $iUserName & '"' If ($sRecurse = Default) Then $sRecurse = 1 If Not FileExists($sFile) Then Return SetError(1, 0, $sFile) If StringInStr(FileGetAttrib($sFile), 'D') <> 0 Then If $sRecurse Then RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '" /R /D Y', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /T /C /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /T /C /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /T /C /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS", 1)) Else RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '" ', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /C /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /C /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /C /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS", 0)) EndIf Else RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '"', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS")) EndIf Return $sFile EndFunc ;==>_TakeOwnership Func _URL_Split($sURL_Input, ByRef $sURL_Protocol, ByRef $sURL_Domain, ByRef $sURL_FilePATH, ByRef $sURL_FileName) Local $sURL_Protocol_Number_Pattern = '^(?s)(?i)(http|ftp|sftp|ftps|https|file)://(.*?/|.*$)(.*/){0,}(.*)$' Local $sURL_Pattern = "^(?i)(?:(?:[a-z]+):\/\/)?" & "(?:(?:(?:[^@:]+))" & "(?::(?:[^@]+))?@)?" & "([^\/:]+)" & "(?::(?:\d+))?" & "(?:\/(?:[^?]+)?)?" & "(?:\?\N+)?" Local $aURL_Pattern = StringRegExp($sURL_Input, $sURL_Protocol_Number_Pattern, 2) If Not IsArray($aURL_Pattern) Or UBound($aURL_Pattern) - 1 <> 4 Then Return SetError(1, 0, 0) If StringRight($aURL_Pattern[2], 1) = '/' Then $aURL_Pattern[2] = StringTrimRight($aURL_Pattern[2], 1) $aURL_Pattern[3] = '/' & $aURL_Pattern[3] EndIf $sURL_Protocol = $aURL_Pattern[1] Local $aHost = StringRegExp($sURL_Input, $sURL_Pattern, 1) If Not @error And IsArray($aHost) Then $sURL_Domain = $aHost[0] Else $sURL_Domain = $aURL_Pattern[2] EndIf $sURL_FilePATH = $aURL_Pattern[3] $sURL_FileName = $aURL_Pattern[4] Return $aURL_Pattern EndFunc ;==>_URL_Split #cs Local $sURL_Protocol, $sURL_Protocol_Number, $sURL_Domain, $sURL_Port, $sURL_User, $sURL_Password, $sURL_FilePathName, $sURL_FilePATH, $sURL_FileName _WinHttp_SplitURL($sURL_Input, $sURL_Protocol, $sURL_Domain, $sURL_Port, $sURL_User, $sURL_Password, $sURL_FilePathName, $sURL_FilePATH, $sURL_FileName) ConsoleWrite("! URL_Input : " & $sURL_Input & @CRLF) ConsoleWrite("- Protocol : " & $sURL_Protocol & @CRLF) ConsoleWrite("- Domain : " & $sURL_Domain & @CRLF) ConsoleWrite("- Port : " & $sURL_Port & @CRLF) ConsoleWrite("- User : " & $sURL_User & @CRLF) ConsoleWrite("- Password : " & $sURL_Password & @CRLF) ConsoleWrite("- FilePathName: " & $sURL_FilePathName & @CRLF) ConsoleWrite("- FilePath : " & $sURL_FilePath & @CRLF) ConsoleWrite("- FileName : " & $sURL_FileName & @CRLF) #ce Func _WinHttp_SplitURL($sURL_Input, ByRef $sURL_Protocol, ByRef $sURL_Domain, ByRef $sURL_Port, ByRef $sURL_User, ByRef $sURL_Password, ByRef $sURL_FilePathName, ByRef $sURL_FilePATH, ByRef $sURL_FileName) If StringStripWS($sURL_Input, 8) = '' Then Return SetError(1, 0, 0) $sURL_Input = StringReplace($sURL_Input, "\", "/") If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input _URL_Split($sURL_Input, $sURL_Protocol, $sURL_Domain, $sURL_FilePATH, $sURL_FileName) StringReplace($sURL_Input, '@', '') If @extended > 1 Then Local $sUser, $aUser = _StringBetween($sURL_Input, $sURL_Protocol & "://", '@') If IsArray($aUser) Then $sUser = $aUser[0] $sURL_Input = StringReplace($sURL_Input, $sURL_Protocol & "://" & $sUser & '@', $sURL_Protocol & "://" & $sUser & '%40') EndIf EndIf Local $ORG_URL_Protocol = $sURL_Protocol, $sFake_Protocol = 'http', $iFake_Protocol = False Switch $sURL_Protocol Case 'http', 'https', 'ftp' Case Else $iFake_Protocol = True $sURL_Input = StringReplace($sURL_Input, $sURL_Protocol & "://", $sFake_Protocol & "://") EndSwitch Local $aUrl = _WinHttpCrackUrl($sURL_Input) If IsArray($aUrl) Then If $iFake_Protocol Then $sURL_Protocol = $ORG_URL_Protocol Else $sURL_Protocol = ($aUrl[0] == '' ? $sURL_Protocol : $aUrl[0]) EndIf ;$sURL_Protocol_Number = $aUrl[1] $sURL_Domain = ($aUrl[2] == '' ? $sURL_Domain : $aUrl[2]) $sURL_Port = $aUrl[3] $sURL_User = StringReplace($aUrl[4], '%40', '@') $sURL_Password = $aUrl[5] $sURL_FilePathName = ($aUrl[6] == '' ? $sURL_FilePATH & $sURL_FileName : $aUrl[6]) ;$sURL_ExtraInfo = $aUrl[7] Return $aUrl EndIf Return SetError(1, 0, "") EndFunc ;==>_WinHttp_SplitURL Func _WinHTTP_GetName_ErrorCode($nErrorCode = 0) ; By Dao Van Trong - TRONG.LIVE Switch $nErrorCode Case 12001 Return "ERROR_WINHTTP_OUT_OF_HANDLES" Case 12002 Return "ERROR_WINHTTP_TIMEOUT" Case 12004 Return "ERROR_WINHTTP_INTERNAL_ERROR" Case 12005 Return "ERROR_WINHTTP_INVALID_URL" Case 12006 Return "ERROR_WINHTTP_UNRECOGNIZED_SCHEME" Case 12007 Return "ERROR_WINHTTP_NAME_NOT_RESOLVED" Case 12009 Return "ERROR_WINHTTP_INVALID_OPTION" Case 12011 Return "ERROR_WINHTTP_OPTION_NOT_SETTABLE" Case 12012 Return "ERROR_WINHTTP_SHUTDOWN" Case 12015 Return "ERROR_WINHTTP_LOGIN_FAILURE" Case 12017 Return "ERROR_WINHTTP_OPERATION_CANCELLED" Case 12018 Return "ERROR_WINHTTP_INCORRECT_HANDLE_TYPE" Case 12019 Return "ERROR_WINHTTP_INCORRECT_HANDLE_STATE" Case 12029 Return "ERROR_WINHTTP_CANNOT_CONNECT" Case 12030 Return "ERROR_WINHTTP_CONNECTION_ERROR" Case 12032 Return "ERROR_WINHTTP_RESEND_REQUEST" Case 12044 Return "ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED" Case 12150 Return "ERROR_WINHTTP_HEADER_NOT_FOUND" Case 12152 Return "ERROR_WINHTTP_INVALID_SERVER_RESPONSE" Case 12153 Return "ERROR_WINHTTP_INVALID_HEADER" Case 12154 Return "ERROR_WINHTTP_INVALID_QUERY_REQUEST" Case 12155 Return "ERROR_WINHTTP_HEADER_ALREADY_EXISTS" Case 12156 Return "ERROR_WINHTTP_REDIRECT_FAILED" Case 12178 Return "ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR" Case 12166 Return "ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT" Case 12167 Return "ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT" Case 12176 Return "ERROR_WINHTTP_UNHANDLED_SCRIPT_TYPE" Case 12177 Return "ERROR_WINHTTP_SCRIPT_EXECUTION_ERROR" Case 12172 Return "ERROR_WINHTTP_NOT_INITIALIZED" Case 12175 Return "ERROR_WINHTTP_SECURE_FAILURE" Case 12037 Return "ERROR_WINHTTP_SECURE_CERT_DATE_INVALID" Case 12038 Return "ERROR_WINHTTP_SECURE_CERT_CN_INVALID" Case 12045 Return "ERROR_WINHTTP_SECURE_INVALID_CA" Case 12057 Return "ERROR_WINHTTP_SECURE_CERT_REV_FAILED" Case 12157 Return "ERROR_WINHTTP_SECURE_CHANNEL_ERROR" Case 12169 Return "ERROR_WINHTTP_SECURE_INVALID_CERT" Case 12170 Return "ERROR_WINHTTP_SECURE_CERT_REVOKED" Case 12179 Return "ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE" Case 12180 Return "ERROR_WINHTTP_AUTODETECTION_FAILED" Case 12181 Return "ERROR_WINHTTP_HEADER_COUNT_EXCEEDED" Case 12182 Return "ERROR_WINHTTP_HEADER_SIZE_OVERFLOW" Case 12183 Return "ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW" Case 12184 Return "ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW" Case 12185 Return "ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY" Case 12186 Return "ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY" Case 12187 Return "ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED_PROXY" Case 12188 Return "ERROR_WINHTTP_SECURE_FAILURE_PROXY" Case 12189 Return "ERROR_WINHTTP_RESERVED_189" Case 12190 Return "ERROR_WINHTTP_HTTP_PROTOCOL_MISMATCH" Case 12191 Return "ERROR_WINHTTP_GLOBAL_CALLBACK_FAILED" Case 12192 Return "ERROR_WINHTTP_FEATURE_DISABLED" Return "WINHTTP_ERROR_LAST" Case Else Return SetError(1, 0, "") EndSwitch EndFunc ;==>_WinHTTP_GetName_ErrorCode Func _WinInet_GetName_ErrorCode($nErrorCode = 0) ; By Dao Van Trong - TRONG.LIVE Switch $nErrorCode Case 12000 Return "INTERNET_ERROR_BASE" Case 12001 Return "ERROR_INTERNET_OUT_OF_HANDLES" Case 12002 Return "ERROR_INTERNET_TIMEOUT" Case 12003 Return "ERROR_INTERNET_EXTENDED_ERROR" Case 12004 Return "ERROR_INTERNET_INTERNAL_ERROR" Case 12005 Return "ERROR_INTERNET_INVALID_URL" Case 12006 Return "ERROR_INTERNET_UNRECOGNIZED_SCHEME" Case 12007 Return "ERROR_INTERNET_NAME_NOT_RESOLVED" Case 12008 Return "ERROR_INTERNET_PROTOCOL_NOT_FOUND" Case 12009 Return "ERROR_INTERNET_INVALID_OPTION" Case 12010 Return "ERROR_INTERNET_BAD_OPTION_LENGTH" Case 12011 Return "ERROR_INTERNET_OPTION_NOT_SETTABLE" Case 12012 Return "ERROR_INTERNET_SHUTDOWN" Case 12013 Return "ERROR_INTERNET_INCORRECT_USER_NAME" Case 12014 Return "ERROR_INTERNET_INCORRECT_PASSWORD" Case 12015 Return "ERROR_INTERNET_LOGIN_FAILURE" Case 12016 Return "ERROR_INTERNET_INVALID_OPERATION" Case 12017 Return "ERROR_INTERNET_OPERATION_CANCELLED" Case 12018 Return "ERROR_INTERNET_INCORRECT_HANDLE_TYPE" Case 12019 Return "ERROR_INTERNET_INCORRECT_HANDLE_STATE" Case 12020 Return "ERROR_INTERNET_NOT_PROXY_REQUEST" Case 12021 Return "ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND" Case 12022 Return "ERROR_INTERNET_BAD_REGISTRY_PARAMETER" Case 12023 Return "ERROR_INTERNET_NO_DIRECT_ACCESS" Case 12024 Return "ERROR_INTERNET_NO_CONTEXT" Case 12025 Return "ERROR_INTERNET_NO_CALLBACK" Case 12026 Return "ERROR_INTERNET_REQUEST_PENDING" Case 12027 Return "ERROR_INTERNET_INCORRECT_FORMAT" Case 12028 Return "ERROR_INTERNET_ITEM_NOT_FOUND" Case 12029 Return "ERROR_INTERNET_CANNOT_CONNECT" Case 12030 Return "ERROR_INTERNET_CONNECTION_ABORTED" Case 12031 Return "ERROR_INTERNET_CONNECTION_RESET" Case 12032 Return "ERROR_INTERNET_FORCE_RETRY" Case 12033 Return "ERROR_INTERNET_INVALID_PROXY_REQUEST" Case 12034 Return "ERROR_INTERNET_NEED_UI" Case 12036 Return "ERROR_INTERNET_HANDLE_EXISTS" Case 12037 Return "ERROR_INTERNET_SEC_CERT_DATE_INVALID" Case 12038 Return "ERROR_INTERNET_SEC_CERT_CN_INVALID" Case 12039 Return "ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR" Case 12040 Return "ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR" Case 12041 Return "ERROR_INTERNET_MIXED_SECURITY" Case 12042 Return "ERROR_INTERNET_CHG_POST_IS_NON_SECURE" Case 12043 Return "ERROR_INTERNET_POST_IS_NON_SECURE" Case 12044 Return "ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED" Case 12045 Return "ERROR_INTERNET_INVALID_CA" Case 12046 Return "ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP" Case 12047 Return "ERROR_INTERNET_ASYNC_THREAD_FAILED" Case 12048 Return "ERROR_INTERNET_REDIRECT_SCHEME_CHANGE" Case 12049 Return "ERROR_INTERNET_DIALOG_PENDING" Case 12050 Return "ERROR_INTERNET_RETRY_DIALOG" Case 12052 Return "ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR" Case 12053 Return "ERROR_INTERNET_INSERT_CDROM" Case 12054 Return "ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED" Case 12055 Return "ERROR_INTERNET_SEC_CERT_ERRORS" Case 12056 Return "ERROR_INTERNET_SEC_CERT_NO_REV" Case 12057 Return "ERROR_INTERNET_SEC_CERT_REV_FAILED" Case 12060 Return "ERROR_HTTP_HSTS_REDIRECT_REQUIRED" Case 12062 Return "ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE" Case 12110 Return "ERROR_FTP_TRANSFER_IN_PROGRESS" Case 12111 Return "ERROR_FTP_DROPPED" Case 12112 Return "ERROR_FTP_NO_PASSIVE_MODE" Case 12130 Return "ERROR_GOPHER_PROTOCOL_ERROR" Case 12131 Return "ERROR_GOPHER_NOT_FILE" Case 12132 Return "ERROR_GOPHER_DATA_ERROR" Case 12133 Return "ERROR_GOPHER_END_OF_DATA" Case 12134 Return "ERROR_GOPHER_INVALID_LOCATOR" Case 12135 Return "ERROR_GOPHER_INCORRECT_LOCATOR_TYPE" Case 12136 Return "ERROR_GOPHER_NOT_GOPHER_PLUS" Case 12137 Return "ERROR_GOPHER_ATTRIBUTE_NOT_FOUND" Case 12138 Return "ERROR_GOPHER_UNKNOWN_LOCATOR" Case 12150 Return "ERROR_HTTP_HEADER_NOT_FOUND" Case 12151 Return "ERROR_HTTP_DOWNLEVEL_SERVER" Case 12152 Return "ERROR_HTTP_INVALID_SERVER_RESPONSE" Case 12153 Return "ERROR_HTTP_INVALID_HEADER" Case 12154 Return "ERROR_HTTP_INVALID_QUERY_REQUEST" Case 12155 Return "ERROR_HTTP_HEADER_ALREADY_EXISTS" Case 12156 Return "ERROR_HTTP_REDIRECT_FAILED" Case 12160 Return "ERROR_HTTP_NOT_REDIRECTED" Case 12161 Return "ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION" Case 12162 Return "ERROR_HTTP_COOKIE_DECLINED" Case 12168 Return "ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION" Case 12157 Return "ERROR_INTERNET_SECURITY_CHANNEL_ERROR" Case 12158 Return "ERROR_INTERNET_UNABLE_TO_CACHE_FILE" Case 12159 Return "ERROR_INTERNET_TCPIP_NOT_INSTALLED" Case 12163 Return "ERROR_INTERNET_DISCONNECTED" Return "ERROR_INTERNET_OFFLINE" Case 12164 Return "ERROR_INTERNET_SERVER_UNREACHABLE" Case 12165 Return "ERROR_INTERNET_PROXY_SERVER_UNREACHABLE" Case 12166 Return "ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT" Case 12167 Return "ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT" Case 12169 Return "ERROR_INTERNET_SEC_INVALID_CERT" Case 12170 Return "ERROR_INTERNET_SEC_CERT_REVOKED" Case 12171 Return "ERROR_INTERNET_FAILED_DUETOSECURITYCHECK" Case 12172 Return "ERROR_INTERNET_NOT_INITIALIZED" Case 12173 Return "ERROR_INTERNET_NEED_MSN_SSPI_PKG" Case 12174 Return "ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY" Case 12175 Return "ERROR_INTERNET_DECODING_FAILED" Case 12187 Return "ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED_PROXY" Case 12188 Return "ERROR_INTERNET_SECURE_FAILURE_PROXY" Case 12190 Return "ERROR_INTERNET_HTTP_PROTOCOL_MISMATCH" Case 12191 Return "ERROR_INTERNET_GLOBAL_CALLBACK_FAILED" Case 12192 Return "ERROR_INTERNET_FEATURE_DISABLED" Return "INTERNET_ERROR_LAST" Case 12051 Return "ERROR_INTERNET_NO_NEW_CONTAINERS" Case 12058 Return "ERROR_INTERNET_SOURCE_PORT_IN_USE" Case 12059 Return "ERROR_INTERNET_INSECURE_FALLBACK_REQUIRED" Case 12061 Return "ERROR_INTERNET_PROXY_ALERT" Case 12080 Return "ERROR_INTERNET_NO_CM_CONNECTION" Case 12147 Return "ERROR_HTTP_PUSH_STATUS_CODE_NOT_SUPPORTED" Case 12148 Return "ERROR_HTTP_PUSH_RETRY_NOT_SUPPORTED" Case 12149 Return "ERROR_HTTP_PUSH_ENABLE_FAILED" Case 12189 Return "ERROR_INTERNET_DISALLOW_INPRIVATE" Case 12900 Return "INTERNET_INTERNAL_ERROR_BASE" Case 12901 Return "ERROR_INTERNET_INTERNAL_SOCKET_ERROR" Case 12902 Return "ERROR_INTERNET_CONNECTION_AVAILABLE" Case 12903 Return "ERROR_INTERNET_NO_KNOWN_SERVERS" Case 12904 Return "ERROR_INTERNET_PING_FAILED" Case 12905 Return "ERROR_INTERNET_NO_PING_SUPPORT" Case 12906 Return "ERROR_INTERNET_CACHE_SUCCESS" Case 12907 Return "ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION_EX" Case Else Return SetError(1, 0, "") EndSwitch EndFunc ;==>_WinInet_GetName_ErrorCode Func _WinAPI_GetLastError(Const $_iCallerError = @error, Const $_iCallerExtended = @extended) Local $aCall = DllCall("kernel32.dll", "dword", "GetLastError") Return SetError($_iCallerError, $_iCallerExtended, $aCall[0]) EndFunc ;==>_WinAPI_GetLastError Func _WinAPI_CloseHandle($hObject) Local $aCall = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hObject) If @error Then Return SetError(@error, @extended, False) Return $aCall[0] EndFunc ;==>_WinAPI_CloseHandle Func _WinAPI_MakeQWord($iLoDWORD, $iHiDWORD) Local $tInt64 = DllStructCreate("uint64") Local $tDwords = DllStructCreate("dword;dword", DllStructGetPtr($tInt64)) DllStructSetData($tDwords, 1, $iLoDWORD) DllStructSetData($tDwords, 2, $iHiDWORD) Return DllStructGetData($tInt64, 1) EndFunc ;==>_WinAPI_MakeQWord Func _FTP_Close($hSession) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $aCall = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $hSession) If @error Or Not $aCall[0] Then Return SetError(@error + 10, _WinAPI_GetLastError(), 0) If $__g_bCallback_FTP = True Then DllCallbackFree($__g_hCallback_FTP) Return $aCall[0] EndFunc ;==>_FTP_Close Func _FTP_Connect($hInternetSession, $sServerName, $sUsername, $sPassword, $iPassive = 0, $iServerPort = 0, $iService = $INTERNET_SERVICE_FTP, $iFlags = $INTERNET_FLAG_DEFAULT, $fuContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) If $iPassive == 1 Then $iFlags = BitOR($iFlags, $INTERNET_FLAG_PASSIVE) Local $ai_InternetConnect = DllCall($__g_hWinInet_FTP, 'hwnd', 'InternetConnectW', 'handle', $hInternetSession, 'wstr', $sServerName, 'ushort', $iServerPort, 'wstr', $sUsername, 'wstr', $sPassword, 'dword', $iService, 'dword', $iFlags, 'dword_ptr', $fuContext) If @error Or $ai_InternetConnect[0] = 0 Then Return SetError(@error + 10, _WinAPI_GetLastError(), 0) Return $ai_InternetConnect[0] EndFunc ;==>_FTP_Connect Func _FTP_FileGet($hFTPSession, $sRemoteFile, $sLocalFile, $bFailIfExists = False, $iFlagsAndAttributes = 0, $iFlags = $FTP_TRANSFER_TYPE_UNKNOWN, $iContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPGetFile = DllCall($__g_hWinInet_FTP, 'bool', 'FtpGetFileW', 'handle', $hFTPSession, 'wstr', $sRemoteFile, 'wstr', $sLocalFile, 'bool', $bFailIfExists, 'dword', $iFlagsAndAttributes, 'dword', $iFlags, 'dword_ptr', $iContext) If @error Or $ai_FTPGetFile[0] = 0 Then Return SetError(@error + 10, _WinAPI_GetLastError(), 0) Return $ai_FTPGetFile[0] EndFunc ;==>_FTP_FileGet Func _FTP_FileGetSize($hFTPSession, $sFileName) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPGetSizeHandle = DllCall($__g_hWinInet_FTP, 'handle', 'FtpOpenFileW', 'handle', $hFTPSession, 'wstr', $sFileName, 'dword', $GENERIC_READ, 'dword', $INTERNET_FLAG_NO_CACHE_WRITE + $INTERNET_FLAG_TRANSFER_BINARY, 'dword_ptr', 0) If @error Then Return SetError(@error, @extended, 0) If $ai_FTPGetSizeHandle[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Local $ai_FTPGetFileSize = DllCall($__g_hWinInet_FTP, 'dword', 'FtpGetFileSize', 'handle', $ai_FTPGetSizeHandle[0], 'dword*', 0) If @error Then Local $iError = @error Local $iExtended = @extended DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FTPGetSizeHandle[0]) Return SetError($iError + 10, $iExtended, 0) EndIf DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FTPGetSizeHandle[0]) Return _WinAPI_MakeQWord($ai_FTPGetFileSize[0], $ai_FTPGetFileSize[2]) EndFunc ;==>_FTP_FileGetSize Func _FTP_GetLastResponseInfo(ByRef $iError, ByRef $sMessage) Local $ai_LastResponseInfo = DllCall($__g_hWinInet_FTP, 'bool', 'InternetGetLastResponseInfoW', 'dword*', 0, 'wstr', "", 'dword*', 4096) If @error Or $ai_LastResponseInfo[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) $iError = $ai_LastResponseInfo[1] $sMessage = $ai_LastResponseInfo[2] Return $ai_LastResponseInfo[0] EndFunc ;==>_FTP_GetLastResponseInfo Func _FTP_Open($sAgent, $iAccessType = $INTERNET_OPEN_TYPE_DIRECT, $sProxyName = '', $sProxyBypass = '', $iFlags = 0) If $__g_hWinInet_FTP = -1 Then __FTP_Init() Local $ai_InternetOpen = DllCall($__g_hWinInet_FTP, 'handle', 'InternetOpenW', 'wstr', $sAgent, 'dword', $iAccessType, 'wstr', $sProxyName, 'wstr', $sProxyBypass, 'dword', $iFlags) If @error Or $ai_InternetOpen[0] = 0 Then Return SetError(@error + 10, _WinAPI_GetLastError(), 0) Return $ai_InternetOpen[0] EndFunc ;==>_FTP_Open Func _FTP_ProgressDownload($hFTPSession, $sLocalFile, $sRemoteFile, $hFunctionToCall = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $hFile = FileOpen($sLocalFile, $FO_OVERWRITE + $FO_BINARY) If $hFile < 0 Then Return SetError(-1, 0, 0) Local $iLasterror, $iError Local $ai_FtpOpenfile = DllCall($__g_hWinInet_FTP, 'handle', 'FtpOpenFileW', 'handle', $hFTPSession, 'wstr', $sRemoteFile, 'dword', $GENERIC_READ, 'dword', $FTP_TRANSFER_TYPE_BINARY, 'dword_ptr', 0) If @error Or $ai_FtpOpenfile[0] = 0 Then $iError = @error $iLasterror = _WinAPI_GetLastError() FileClose($hFile) Return SetError($iError + 10, $iLasterror, 0) EndIf Local $ai_FTPGetFileSize = DllCall($__g_hWinInet_FTP, 'dword', 'FtpGetFileSize', 'handle', $ai_FtpOpenfile[0], 'dword*', 0) If @error Then $iError = @error DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) Return SetError($iError + 20, 0, 0) EndIf If Not IsFunc($hFunctionToCall) Then ProgressOn("FTP Download", "Downloading " & $sLocalFile) Local $iLen = _WinAPI_MakeQWord($ai_FTPGetFileSize[0], $ai_FTPGetFileSize[2]) Local Const $iChunkSize = 256 * 1024 Local $iLast = Mod($iLen, $iChunkSize) Local $iParts = Ceiling($iLen / $iChunkSize) Local $tBuffer = DllStructCreate("byte[" & $iChunkSize & "]") Local $aCall, $ai_FTPread, $iOut, $iRet Local $x = $iChunkSize Local $iDone = 0 For $i = 1 To $iParts If $i = $iParts And $iLast > 0 Then $x = $iLast EndIf $ai_FTPread = DllCall($__g_hWinInet_FTP, 'bool', 'InternetReadFile', 'handle', $ai_FtpOpenfile[0], 'struct*', $tBuffer, 'dword', $x, 'dword*', $iOut) If @error Or $ai_FTPread[0] = 0 Then $iError = @error $iLasterror = _WinAPI_GetLastError() DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError($iError + 30, $iLasterror, 0) EndIf $iRet = FileWrite($hFile, BinaryMid(DllStructGetData($tBuffer, 1), 1, $ai_FTPread[4])) If Not $iRet Then $iLasterror = _WinAPI_GetLastError() DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) FileDelete($sLocalFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError(-7, $iLasterror, 0) EndIf $iDone += $ai_FTPread[4] If Not IsFunc($hFunctionToCall) Then ProgressSet(($iDone / $iLen) * 100) Else $iRet = $hFunctionToCall(($iDone / $iLen) * 100) If $iRet <= 0 Then $iLasterror = @error DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) FileDelete($sLocalFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError(-6, $iLasterror, $iRet) EndIf EndIf Sleep(10) Next FileClose($hFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() $aCall = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) If @error Or Not $aCall[0] Then Return SetError(@error + 40, _WinAPI_GetLastError(), 0) EndIf Return 1 EndFunc ;==>_FTP_ProgressDownload Func __FTP_Init() $__g_hWinInet_FTP = DllOpen('wininet.dll') EndFunc ;==>__FTP_Init Func _WinAPI_CreateFileEx($sFilePath, $iCreation, $iAccess = 0, $iShare = 0, $iFlagsAndAttributes = 0, $tSecurity = 0, $hTemplate = 0) Local $aCall = DllCall('kernel32.dll', 'handle', 'CreateFileW', 'wstr', $sFilePath, 'dword', $iAccess, 'dword', $iShare, 'struct*', $tSecurity, 'dword', $iCreation, 'dword', $iFlagsAndAttributes, 'handle', $hTemplate) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] = Ptr(-1) Then Return SetError(10, _WinAPI_GetLastError(), 0) Return $aCall[0] EndFunc ;==>_WinAPI_CreateFileEx Func _WinAPI_Wow64EnableWow64FsRedirection($bEnable) Local $aCall = DllCall('kernel32.dll', 'boolean', 'Wow64EnableWow64FsRedirection', 'boolean', $bEnable) If @error Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc ;==>_WinAPI_Wow64EnableWow64FsRedirection Func _StringBetween($sString, $sStart, $sEnd, $iMode = $STR_ENDISSTART, $bCase = False) $sStart = $sStart ? "\Q" & $sStart & "\E" : "\A" If $iMode <> $STR_ENDNOTSTART Then $iMode = $STR_ENDISSTART If $iMode = $STR_ENDISSTART Then $sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z" Else $sEnd = $sEnd ? "\Q" & $sEnd & "\E" : "\z" EndIf If $bCase = Default Then $bCase = False EndIf Local $aRet = StringRegExp($sString, "(?s" & (Not $bCase ? "i" : "") & ")" & $sStart & "(.*?)" & $sEnd, $STR_REGEXPARRAYGLOBALMATCH) If @error Then Return SetError(1, 0, 0) Return $aRet EndFunc ;==>_StringBetween Func _WinHttpCloseHandle($hInternet) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpCloseHandle", "handle", $hInternet) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinHttpCloseHandle Func _WinHttpConnect($hSession, $sServerName, $iServerPort = Default) Local $aURL = _WinHttpCrackUrl($sServerName), $iScheme = 0 If @error Then __WinHttpDefault($iServerPort, $INTERNET_DEFAULT_PORT) Else $sServerName = $aURL[2] $iServerPort = $aURL[3] $iScheme = $aURL[1] EndIf Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "handle", "WinHttpConnect", "handle", $hSession, "wstr", $sServerName, "dword", $iServerPort, "dword", 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) _WinHttpSetOption($aCall[0], $WINHTTP_OPTION_CONTEXT_VALUE, $iScheme) Return $aCall[0] EndFunc ;==>_WinHttpConnect Func _WinHttpCrackUrl($sURL, $iFlag = Default) __WinHttpDefault($iFlag, $ICU_ESCAPE) Local $tURL_COMPONENTS = DllStructCreate("dword StructSize;" & "ptr SchemeName;" & "dword SchemeNameLength;" & "int Scheme;" & "ptr HostName;" & "dword HostNameLength;" & "word Port;" & "ptr UserName;" & "dword UserNameLength;" & "ptr Password;" & "dword PasswordLength;" & "ptr UrlPath;" & "dword UrlPathLength;" & "ptr ExtraInfo;" & "dword ExtraInfoLength") DllStructSetData($tURL_COMPONENTS, 1, DllStructGetSize($tURL_COMPONENTS)) Local $tBuffers[6] Local $iURLLen = StringLen($sURL) For $i = 0 To 5 $tBuffers[$i] = DllStructCreate("wchar[" & $iURLLen + 1 & "]") Next DllStructSetData($tURL_COMPONENTS, "SchemeNameLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "SchemeName", DllStructGetPtr($tBuffers[0])) DllStructSetData($tURL_COMPONENTS, "HostNameLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "HostName", DllStructGetPtr($tBuffers[1])) DllStructSetData($tURL_COMPONENTS, "UserNameLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "UserName", DllStructGetPtr($tBuffers[2])) DllStructSetData($tURL_COMPONENTS, "PasswordLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "Password", DllStructGetPtr($tBuffers[3])) DllStructSetData($tURL_COMPONENTS, "UrlPathLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "UrlPath", DllStructGetPtr($tBuffers[4])) DllStructSetData($tURL_COMPONENTS, "ExtraInfoLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "ExtraInfo", DllStructGetPtr($tBuffers[5])) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpCrackUrl", "wstr", $sURL, "dword", $iURLLen, "dword", $iFlag, "struct*", $tURL_COMPONENTS) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Local $aRet[8] = [DllStructGetData($tBuffers[0], 1), DllStructGetData($tURL_COMPONENTS, "Scheme"), DllStructGetData($tBuffers[1], 1), DllStructGetData($tURL_COMPONENTS, "Port"), DllStructGetData($tBuffers[2], 1), DllStructGetData($tBuffers[3], 1), DllStructGetData($tBuffers[4], 1), DllStructGetData($tBuffers[5], 1)] Return $aRet EndFunc ;==>_WinHttpCrackUrl Func _WinHttpOpen($sUserAgent = Default, $iAccessType = Default, $sProxyName = Default, $sProxyBypass = Default, $iFlag = Default) __WinHttpDefault($sUserAgent, __WinHttpUA()) __WinHttpDefault($iAccessType, $WINHTTP_ACCESS_TYPE_NO_PROXY) __WinHttpDefault($sProxyName, $WINHTTP_NO_PROXY_NAME) __WinHttpDefault($sProxyBypass, $WINHTTP_NO_PROXY_BYPASS) __WinHttpDefault($iFlag, 0) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "handle", "WinHttpOpen", "wstr", $sUserAgent, "dword", $iAccessType, "wstr", $sProxyName, "wstr", $sProxyBypass, "dword", $iFlag) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) If $iFlag = $WINHTTP_FLAG_ASYNC Then _WinHttpSetOption($aCall[0], $WINHTTP_OPTION_CONTEXT_VALUE, $WINHTTP_FLAG_ASYNC) Return $aCall[0] EndFunc ;==>_WinHttpOpen Func _WinHttpOpenRequest($hConnect, $sVerb = Default, $sObjectName = Default, $sVersion = Default, $sReferrer = Default, $sAcceptTypes = Default, $iFlags = Default) __WinHttpDefault($sVerb, "GET") __WinHttpDefault($sObjectName, "") __WinHttpDefault($sVersion, "HTTP/1.1") __WinHttpDefault($sReferrer, $WINHTTP_NO_REFERER) __WinHttpDefault($iFlags, $WINHTTP_FLAG_ESCAPE_DISABLE) Local $pAcceptTypes If $sAcceptTypes = Default Or Number($sAcceptTypes) = -1 Then $pAcceptTypes = $WINHTTP_DEFAULT_ACCEPT_TYPES Else Local $aTypes = StringSplit($sAcceptTypes, ",", 2) Local $tAcceptTypes = DllStructCreate("ptr[" & UBound($aTypes) + 1 & "]") Local $tType[UBound($aTypes)] For $i = 0 To UBound($aTypes) - 1 $tType[$i] = DllStructCreate("wchar[" & StringLen($aTypes[$i]) + 1 & "]") DllStructSetData($tType[$i], 1, $aTypes[$i]) DllStructSetData($tAcceptTypes, 1, DllStructGetPtr($tType[$i]), $i + 1) Next $pAcceptTypes = DllStructGetPtr($tAcceptTypes) EndIf Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "handle", "WinHttpOpenRequest", "handle", $hConnect, "wstr", StringUpper($sVerb), "wstr", $sObjectName, "wstr", StringUpper($sVersion), "wstr", $sReferrer, "ptr", $pAcceptTypes, "dword", $iFlags) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ;==>_WinHttpOpenRequest Func _WinHttpQueryAuthSchemes($hRequest, ByRef $iSupportedSchemes, ByRef $iFirstScheme, ByRef $iAuthTarget) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpQueryAuthSchemes", "handle", $hRequest, "dword*", 0, "dword*", 0, "dword*", 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) $iSupportedSchemes = $aCall[2] $iFirstScheme = $aCall[3] $iAuthTarget = $aCall[4] Return 1 EndFunc ;==>_WinHttpQueryAuthSchemes Func _WinHttpQueryDataAvailable($hRequest) Local $sReadType = "dword*" If BitAND(_WinHttpQueryOption(_WinHttpQueryOption(_WinHttpQueryOption($hRequest, $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_CONTEXT_VALUE), $WINHTTP_FLAG_ASYNC) Then $sReadType = "ptr" Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpQueryDataAvailable", "handle", $hRequest, $sReadType, 0) If @error Then Return SetError(1, 0, 0) Return SetExtended($aCall[2], $aCall[0]) EndFunc ;==>_WinHttpQueryDataAvailable Func _WinHttpQueryHeaders($hRequest, $iInfoLevel = Default, $sName = Default, $iIndex = Default) __WinHttpDefault($iInfoLevel, $WINHTTP_QUERY_RAW_HEADERS_CRLF) __WinHttpDefault($sName, $WINHTTP_HEADER_NAME_BY_INDEX) __WinHttpDefault($iIndex, $WINHTTP_NO_HEADER_INDEX) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpQueryHeaders", "handle", $hRequest, "dword", $iInfoLevel, "wstr", $sName, "wstr", "", "dword*", 65536, "dword*", $iIndex) If @error Or Not $aCall[0] Then Return SetError(1, 0, "") Return SetExtended($aCall[6], $aCall[4]) EndFunc ;==>_WinHttpQueryHeaders Func _WinHttpQueryOption($hInternet, $iOption) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpQueryOption", "handle", $hInternet, "dword", $iOption, "ptr", 0, "dword*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, "") Local $iSize = $aCall[4] Local $tBuffer Switch $iOption Case $WINHTTP_OPTION_CONNECTION_INFO, $WINHTTP_OPTION_PASSWORD, $WINHTTP_OPTION_PROXY_PASSWORD, $WINHTTP_OPTION_PROXY_USERNAME, $WINHTTP_OPTION_URL, $WINHTTP_OPTION_USERNAME, $WINHTTP_OPTION_USER_AGENT, $WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT, $WINHTTP_OPTION_PASSPORT_COBRANDING_URL $tBuffer = DllStructCreate("wchar[" & $iSize + 1 & "]") Case $WINHTTP_OPTION_PARENT_HANDLE, $WINHTTP_OPTION_CALLBACK, $WINHTTP_OPTION_SERVER_CERT_CONTEXT $tBuffer = DllStructCreate("ptr") Case $WINHTTP_OPTION_CONNECT_TIMEOUT, $WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH, $WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW, $WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM, $WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH, $WINHTTP_OPTION_CONNECT_RETRIES, $WINHTTP_OPTION_EXTENDED_ERROR, $WINHTTP_OPTION_HANDLE_TYPE, $WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER, $WINHTTP_OPTION_MAX_CONNS_PER_SERVER, $WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS, $WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, $WINHTTP_OPTION_RECEIVE_TIMEOUT, $WINHTTP_OPTION_RESOLVE_TIMEOUT, $WINHTTP_OPTION_SECURITY_FLAGS, $WINHTTP_OPTION_SECURITY_KEY_BITNESS, $WINHTTP_OPTION_SEND_TIMEOUT $tBuffer = DllStructCreate("int") Case $WINHTTP_OPTION_CONTEXT_VALUE $tBuffer = DllStructCreate("dword_ptr") Case Else $tBuffer = DllStructCreate("byte[" & $iSize & "]") EndSwitch $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpQueryOption", "handle", $hInternet, "dword", $iOption, "struct*", $tBuffer, "dword*", $iSize) If @error Or Not $aCall[0] Then Return SetError(2, 0, "") Return DllStructGetData($tBuffer, 1) EndFunc ;==>_WinHttpQueryOption Func _WinHttpReadData($hRequest, $iMode = Default, $iNumberOfBytesToRead = Default, $pBuffer = Default) __WinHttpDefault($iMode, 0) __WinHttpDefault($iNumberOfBytesToRead, 8192) Local $tBuffer, $vOutOnError = "" If $iMode = 2 Then $vOutOnError = Binary($vOutOnError) Switch $iMode Case 1, 2 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]") EndIf Case Else $iMode = 0 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]") EndIf EndSwitch Local $sReadType = "dword*" If BitAND(_WinHttpQueryOption(_WinHttpQueryOption(_WinHttpQueryOption($hRequest, $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_CONTEXT_VALUE), $WINHTTP_FLAG_ASYNC) Then $sReadType = "ptr" Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpReadData", "handle", $hRequest, "struct*", $tBuffer, "dword", $iNumberOfBytesToRead, $sReadType, 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, "") If Not $aCall[4] Then Return SetError(-1, 0, $vOutOnError) If $aCall[4] < $iNumberOfBytesToRead Then Switch $iMode Case 0 Return SetExtended($aCall[4], StringLeft(DllStructGetData($tBuffer, 1), $aCall[4])) Case 1 Return SetExtended($aCall[4], BinaryToString(BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4]), 4)) Case 2 Return SetExtended($aCall[4], BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4])) EndSwitch Else Switch $iMode Case 0, 2 Return SetExtended($aCall[4], DllStructGetData($tBuffer, 1)) Case 1 Return SetExtended($aCall[4], BinaryToString(DllStructGetData($tBuffer, 1), 4)) EndSwitch EndIf EndFunc ;==>_WinHttpReadData Func _WinHttpReceiveResponse($hRequest) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpReceiveResponse", "handle", $hRequest, "ptr", 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinHttpReceiveResponse Func _WinHttpSendRequest($hRequest, $sHeaders = Default, $vOptional = Default, $iTotalLength = Default, $iContext = Default) __WinHttpDefault($sHeaders, $WINHTTP_NO_ADDITIONAL_HEADERS) __WinHttpDefault($vOptional, $WINHTTP_NO_REQUEST_DATA) __WinHttpDefault($iTotalLength, 0) __WinHttpDefault($iContext, 0) Local $pOptional = 0, $iOptionalLength = 0 If @NumParams > 2 Then Local $tOptional $iOptionalLength = BinaryLen($vOptional) $tOptional = DllStructCreate("byte[" & $iOptionalLength & "]") If $iOptionalLength Then $pOptional = DllStructGetPtr($tOptional) DllStructSetData($tOptional, 1, $vOptional) EndIf If Not $iTotalLength Or $iTotalLength < $iOptionalLength Then $iTotalLength += $iOptionalLength Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpSendRequest", "handle", $hRequest, "wstr", $sHeaders, "dword", 0, "ptr", $pOptional, "dword", $iOptionalLength, "dword", $iTotalLength, "dword_ptr", $iContext) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinHttpSendRequest Func _WinHttpSetCredentials($hRequest, $iAuthTargets, $iAuthScheme, $sUserName, $sPassword) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpSetCredentials", "handle", $hRequest, "dword", $iAuthTargets, "dword", $iAuthScheme, "wstr", $sUserName, "wstr", $sPassword, "ptr", 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinHttpSetCredentials Func _WinHttpSetOption($hInternet, $iOption, $vSetting, $iSize = Default) If $iSize = Default Then $iSize = -1 If IsBinary($vSetting) Then $iSize = DllStructCreate("byte[" & BinaryLen($vSetting) & "]") DllStructSetData($iSize, 1, $vSetting) $vSetting = $iSize $iSize = DllStructGetSize($vSetting) EndIf Local $sType Switch $iOption Case $WINHTTP_OPTION_AUTOLOGON_POLICY, $WINHTTP_OPTION_CODEPAGE, $WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH, $WINHTTP_OPTION_CONNECT_RETRIES, $WINHTTP_OPTION_CONNECT_TIMEOUT, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_OPTION_ENABLE_FEATURE, $WINHTTP_OPTION_ENABLETRACING, $WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER, $WINHTTP_OPTION_MAX_CONNS_PER_SERVER, $WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS, $WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE, $WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE, $WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE, $WINHTTP_OPTION_READ_BUFFER_SIZE, $WINHTTP_OPTION_RECEIVE_TIMEOUT, $WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, $WINHTTP_OPTION_REDIRECT_POLICY, $WINHTTP_OPTION_REJECT_USERPWD_IN_URL, $WINHTTP_OPTION_REQUEST_PRIORITY, $WINHTTP_OPTION_RESOLVE_TIMEOUT, $WINHTTP_OPTION_SECURE_PROTOCOLS, $WINHTTP_OPTION_SECURITY_FLAGS, $WINHTTP_OPTION_SECURITY_KEY_BITNESS, $WINHTTP_OPTION_SEND_TIMEOUT, $WINHTTP_OPTION_SPN, $WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS, $WINHTTP_OPTION_WORKER_THREAD_COUNT, $WINHTTP_OPTION_WRITE_BUFFER_SIZE, $WINHTTP_OPTION_DECOMPRESSION, $WINHTTP_OPTION_UNSAFE_HEADER_PARSING $sType = "dword*" $iSize = 4 Case $WINHTTP_OPTION_CALLBACK, $WINHTTP_OPTION_PASSPORT_SIGN_OUT $sType = "ptr*" $iSize = 4 If @AutoItX64 Then $iSize = 8 If Not IsPtr($vSetting) Then Return SetError(3, 0, 0) Case $WINHTTP_OPTION_CONTEXT_VALUE $sType = "dword_ptr*" $iSize = 4 If @AutoItX64 Then $iSize = 8 Case $WINHTTP_OPTION_PASSWORD, $WINHTTP_OPTION_PROXY_PASSWORD, $WINHTTP_OPTION_PROXY_USERNAME, $WINHTTP_OPTION_USER_AGENT, $WINHTTP_OPTION_USERNAME $sType = "wstr" If (IsDllStruct($vSetting) Or IsPtr($vSetting)) Then Return SetError(3, 0, 0) If $iSize < 1 Then $iSize = StringLen($vSetting) Case $WINHTTP_OPTION_CLIENT_CERT_CONTEXT, $WINHTTP_OPTION_GLOBAL_PROXY_CREDS, $WINHTTP_OPTION_GLOBAL_SERVER_CREDS, $WINHTTP_OPTION_HTTP_VERSION, $WINHTTP_OPTION_PROXY $sType = "ptr" If Not (IsDllStruct($vSetting) Or IsPtr($vSetting)) Then Return SetError(3, 0, 0) Case Else Return SetError(1, 0, 0) EndSwitch If $iSize < 1 Then If IsDllStruct($vSetting) Then $iSize = DllStructGetSize($vSetting) Else Return SetError(2, 0, 0) EndIf EndIf Local $aCall If IsDllStruct($vSetting) Then $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpSetOption", "handle", $hInternet, "dword", $iOption, $sType, DllStructGetPtr($vSetting), "dword", $iSize) Else $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpSetOption", "handle", $hInternet, "dword", $iOption, $sType, $vSetting, "dword", $iSize) EndIf If @error Or Not $aCall[0] Then Return SetError(4, 0, 0) Return 1 EndFunc ;==>_WinHttpSetOption Func _WinHttpSimpleFormFill_SetUploadCallback($vCallback = Default, $iNumChunks = 100) If $iNumChunks <= 0 Then $iNumChunks = 100 Local Static $vFunc = Default, $iParts = $iNumChunks If $vCallback <> Default Then $vFunc = $vCallback $iParts = Ceiling($iNumChunks) ElseIf $vCallback = 0 Then $vFunc = Default $iParts = 1 EndIf Local $aOut[2] = [$vFunc, $iParts] Return $aOut EndFunc ;==>_WinHttpSimpleFormFill_SetUploadCallback Func _WinHttpSimpleReadData($hRequest, $iMode = Default) If $iMode = Default Then $iMode = 0 If __WinHttpCharSet(_WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_TYPE)) = 65001 Then $iMode = 1 Else __WinHttpDefault($iMode, 0) EndIf If $iMode > 2 Or $iMode < 0 Then Return SetError(1, 0, '') Local $vData = Binary('') If _WinHttpQueryDataAvailable($hRequest) Then Do $vData &= _WinHttpReadData($hRequest, 2) Until @error Switch $iMode Case 0 Return BinaryToString($vData) Case 1 Return BinaryToString($vData, 4) Case Else Return $vData EndSwitch EndIf Return SetError(2, 0, $vData) EndFunc ;==>_WinHttpSimpleReadData Func _WinHttpSimpleRequest($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sDta = Default, $sHeader = Default, $fGetHeaders = Default, $iMode = Default, $sCredName = Default, $sCredPass = Default) __WinHttpDefault($sType, "GET") __WinHttpDefault($sPath, "") __WinHttpDefault($sReferrer, $WINHTTP_NO_REFERER) __WinHttpDefault($sDta, $WINHTTP_NO_REQUEST_DATA) __WinHttpDefault($sHeader, $WINHTTP_NO_ADDITIONAL_HEADERS) __WinHttpDefault($fGetHeaders, False) __WinHttpDefault($iMode, Default) __WinHttpDefault($sCredName, "") __WinHttpDefault($sCredPass, "") If $iMode > 2 Or $iMode < 0 Then Return SetError(4, 0, 0) Local $hRequest = _WinHttpSimpleSendRequest($hConnect, $sType, $sPath, $sReferrer, $sDta, $sHeader) If @error Then Return SetError(@error, 0, 0) __WinHttpSetCredentials($hRequest, $sHeader, $sDta, $sCredName, $sCredPass) Local $iExtended = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE) If $fGetHeaders Then Local $aData[3] = [_WinHttpQueryHeaders($hRequest), _WinHttpSimpleReadData($hRequest, $iMode), _WinHttpQueryOption($hRequest, $WINHTTP_OPTION_URL)] _WinHttpCloseHandle($hRequest) Return SetExtended($iExtended, $aData) EndIf Local $sOutData = _WinHttpSimpleReadData($hRequest, $iMode) _WinHttpCloseHandle($hRequest) Return SetExtended($iExtended, $sOutData) EndFunc ;==>_WinHttpSimpleRequest Func _WinHttpSimpleSendRequest($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sDta = Default, $sHeader = Default) __WinHttpDefault($sType, "GET") __WinHttpDefault($sPath, "") __WinHttpDefault($sReferrer, $WINHTTP_NO_REFERER) __WinHttpDefault($sDta, $WINHTTP_NO_REQUEST_DATA) __WinHttpDefault($sHeader, $WINHTTP_NO_ADDITIONAL_HEADERS) Local $hRequest = _WinHttpOpenRequest($hConnect, $sType, $sPath, Default, $sReferrer) If Not $hRequest Then Return SetError(1, @error, 0) If $sType = "POST" And $sHeader = $WINHTTP_NO_ADDITIONAL_HEADERS Then $sHeader = "Content-Type: application/x-www-form-urlencoded" & @CRLF _WinHttpSetOption($hRequest, $WINHTTP_OPTION_DECOMPRESSION, $WINHTTP_DECOMPRESSION_FLAG_ALL) _WinHttpSetOption($hRequest, $WINHTTP_OPTION_UNSAFE_HEADER_PARSING, 1) _WinHttpSendRequest($hRequest, $sHeader, $sDta) If @error Then Return SetError(2, 0 * _WinHttpCloseHandle($hRequest), 0) _WinHttpReceiveResponse($hRequest) If @error Then Return SetError(3, 0 * _WinHttpCloseHandle($hRequest), 0) Return $hRequest EndFunc ;==>_WinHttpSimpleSendRequest Func _WinHttpSimpleSendSSLRequest($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sDta = Default, $sHeader = Default, $iIgnoreAllCertErrors = 0) __WinHttpDefault($sType, "GET") __WinHttpDefault($sPath, "") __WinHttpDefault($sReferrer, $WINHTTP_NO_REFERER) __WinHttpDefault($sDta, $WINHTTP_NO_REQUEST_DATA) __WinHttpDefault($sHeader, $WINHTTP_NO_ADDITIONAL_HEADERS) Local $hRequest = _WinHttpOpenRequest($hConnect, $sType, $sPath, Default, $sReferrer, Default, BitOR($WINHTTP_FLAG_SECURE, $WINHTTP_FLAG_ESCAPE_DISABLE)) If Not $hRequest Then Return SetError(1, @error, 0) If $iIgnoreAllCertErrors Then _WinHttpSetOption($hRequest, $WINHTTP_OPTION_SECURITY_FLAGS, BitOR($SECURITY_FLAG_IGNORE_UNKNOWN_CA, $SECURITY_FLAG_IGNORE_CERT_DATE_INVALID, $SECURITY_FLAG_IGNORE_CERT_CN_INVALID, $SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)) If $sType = "POST" And $sHeader = $WINHTTP_NO_ADDITIONAL_HEADERS Then $sHeader = "Content-Type: application/x-www-form-urlencoded" & @CRLF _WinHttpSetOption($hRequest, $WINHTTP_OPTION_DECOMPRESSION, $WINHTTP_DECOMPRESSION_FLAG_ALL) _WinHttpSetOption($hRequest, $WINHTTP_OPTION_UNSAFE_HEADER_PARSING, 1) _WinHttpSendRequest($hRequest, $sHeader, $sDta) If @error Then Return SetError(2, 0 * _WinHttpCloseHandle($hRequest), 0) _WinHttpReceiveResponse($hRequest) If @error Then Return SetError(3, 0 * _WinHttpCloseHandle($hRequest), 0) Return $hRequest EndFunc ;==>_WinHttpSimpleSendSSLRequest Func _WinHttpSimpleSSLRequest($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sDta = Default, $sHeader = Default, $fGetHeaders = Default, $iMode = Default, $sCredName = Default, $sCredPass = Default, $iIgnoreCertErrors = 0) __WinHttpDefault($sType, "GET") __WinHttpDefault($sPath, "") __WinHttpDefault($sReferrer, $WINHTTP_NO_REFERER) __WinHttpDefault($sDta, $WINHTTP_NO_REQUEST_DATA) __WinHttpDefault($sHeader, $WINHTTP_NO_ADDITIONAL_HEADERS) __WinHttpDefault($fGetHeaders, False) __WinHttpDefault($iMode, Default) __WinHttpDefault($sCredName, "") __WinHttpDefault($sCredPass, "") If $iMode > 2 Or $iMode < 0 Then Return SetError(4, 0, 0) Local $hRequest = _WinHttpSimpleSendSSLRequest($hConnect, $sType, $sPath, $sReferrer, $sDta, $sHeader, $iIgnoreCertErrors) If @error Then Return SetError(@error, 0, 0) __WinHttpSetCredentials($hRequest, $sHeader, $sDta, $sCredName, $sCredPass) If $fGetHeaders Then Local $aData[3] = [_WinHttpQueryHeaders($hRequest), _WinHttpSimpleReadData($hRequest, $iMode), _WinHttpQueryOption($hRequest, $WINHTTP_OPTION_URL)] _WinHttpCloseHandle($hRequest) Return $aData EndIf Local $sOutData = _WinHttpSimpleReadData($hRequest, $iMode) _WinHttpCloseHandle($hRequest) Return $sOutData EndFunc ;==>_WinHttpSimpleSSLRequest Func _WinHttpWriteData($hRequest, $vData, $iMode = Default) __WinHttpDefault($iMode, 0) Local $iNumberOfBytesToWrite, $tData If $iMode = 1 Then $iNumberOfBytesToWrite = BinaryLen($vData) $tData = DllStructCreate("byte[" & $iNumberOfBytesToWrite & "]") DllStructSetData($tData, 1, $vData) ElseIf IsDllStruct($vData) Then $iNumberOfBytesToWrite = DllStructGetSize($vData) $tData = $vData Else $iNumberOfBytesToWrite = StringLen($vData) $tData = DllStructCreate("char[" & $iNumberOfBytesToWrite + 1 & "]") DllStructSetData($tData, 1, $vData) EndIf Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpWriteData", "handle", $hRequest, "struct*", $tData, "dword", $iNumberOfBytesToWrite, "dword*", 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return SetExtended($aCall[4], 1) EndFunc ;==>_WinHttpWriteData Func __WinHttpCharSet($sContentType) Local $aContentType = StringRegExp($sContentType, "(?i).*?\Qcharset=\E(?U)([^ ]+)(;| |\Z)", 2) If Not @error Then $sContentType = $aContentType[1] If StringLeft($sContentType, 2) = "cp" Then Return Int(StringTrimLeft($sContentType, 2)) If $sContentType = "utf-8" Then Return 65001 EndFunc ;==>__WinHttpCharSet Func __WinHttpSetCredentials($hRequest, $sHeaders = "", $sOptional = "", $sCredName = "", $sCredPass = "", $iFormFill = 0) If $sCredName And $sCredPass Then Local $iStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE) If $iStatusCode = $HTTP_STATUS_DENIED Or $iStatusCode = $HTTP_STATUS_PROXY_AUTH_REQ Then Local $iSupportedSchemes, $iFirstScheme, $iAuthTarget If _WinHttpQueryAuthSchemes($hRequest, $iSupportedSchemes, $iFirstScheme, $iAuthTarget) Then If $iFirstScheme = $WINHTTP_AUTH_SCHEME_PASSPORT And $iStatusCode = $HTTP_STATUS_PROXY_AUTH_REQ Then _WinHttpSetOption($hRequest, $WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH, $WINHTTP_ENABLE_PASSPORT_AUTH) _WinHttpSetOption($hRequest, $WINHTTP_OPTION_PROXY_USERNAME, $sCredName) _WinHttpSetOption($hRequest, $WINHTTP_OPTION_PROXY_PASSWORD, $sCredPass) Else _WinHttpSetCredentials($hRequest, $iAuthTarget, $iFirstScheme, $sCredName, $sCredPass) EndIf If $iFormFill Then __WinHttpFormUpload($hRequest, $sHeaders, $sOptional) Else _WinHttpSendRequest($hRequest, $sHeaders, $sOptional) EndIf _WinHttpReceiveResponse($hRequest) EndIf EndIf EndIf EndFunc ;==>__WinHttpSetCredentials Func __WinHttpFormUpload($hRequest, $sHeaders, $sData) Local $aClbk = _WinHttpSimpleFormFill_SetUploadCallback() If $aClbk[0] <> Default Then Local $iSize = StringLen($sData), $iChunk = Floor($iSize / $aClbk[1]), $iRest = $iSize - ($aClbk[1] - 1) * $iChunk, $iCurCh = $iChunk _WinHttpSendRequest($hRequest, Default, Default, $iSize) For $i = 1 To $aClbk[1] If $i = $aClbk[1] Then $iCurCh = $iRest _WinHttpWriteData($hRequest, StringMid($sData, 1 + $iChunk * ($i - 1), $iCurCh)) Call($aClbk[0], Floor($i * 100 / $aClbk[1])) Next Else _WinHttpSendRequest($hRequest, Default, $sData) EndIf EndFunc ;==>__WinHttpFormUpload Func __WinHttpDefault(ByRef $vInput, $vOutput) If $vInput = Default Or Number($vInput) = -1 Then $vInput = $vOutput EndFunc ;==>__WinHttpDefault Func __WinHttpUA() Local Static $sUA = "Mozilla/5.0 " & __WinHttpSysInfo() & " WinHttp/" & __WinHttpVer() & " (WinHTTP/5.1) like Gecko" Return $sUA EndFunc ;==>__WinHttpUA Func __WinHttpSysInfo() Local $sDta = FileGetVersion("kernel32.dll") $sDta = "(Windows NT " & StringLeft($sDta, StringInStr($sDta, ".", 1, 2) - 1) If StringInStr(@OSArch, "64") And Not @AutoItX64 Then $sDta &= "; WOW64" $sDta &= ")" Return $sDta EndFunc ;==>__WinHttpSysInfo Func __WinHttpVer() Return "1.6.4.1" EndFunc ;==>__WinHttpVer
    1 point
  5. If GUICtrlRead($Checkbox_1) = $GUI_CHECKED And Not WinExists($clientA) Then MsgBox(0, "My Title", "Client is not running") ShellExecute($client1) Else MsgBox(0, "My Title", "Client is running or $Checkbox_1 is unCheck") EndIf
    1 point
  6. something like this ? If WinExists($clientA) Then MsgBox("Title", "The client is already open.", 10) Else MsgBox("Title", "Does not excist starting up now.", 10) ShellExecute($client1) WinWait($client1) EndIf If GUICtrlRead($Checkbox_1) = $GUI_CHECKED Then EndIf
    1 point
  7. ;__ExampleA() __ExampleB() Func __ExampleA() ConsoleWrite('> Example1 ' & @crlf) __MakeAPIRequest1(__All_Global_A()) ConsoleWrite('> Example2 ' & @crlf) __MakeAPIRequest2(__All_Global_A(0), __All_Global_A(1), __All_Global_A(2)) ConsoleWrite('> Example3 ' & @crlf) __MakeAPIRequest2(__All_Global_A('$API_KEY'), __All_Global_A('$API_ENDPOINT'), __All_Global_A('$API_SECRETKEY')) EndFunc Func __ExampleB() ConsoleWrite('> Example1 ' & @crlf) __MakeAPIRequest1(__All_Global_B()) ConsoleWrite('> Example2 ' & @crlf) __MakeAPIRequest2(__All_Global_B(0), __All_Global_B(1), __All_Global_B(2)) ConsoleWrite('> Example3 ' & @crlf) __MakeAPIRequest2(__All_Global_B('$API_KEY'), __All_Global_B('$API_ENDPOINT'), __All_Global_B('$API_SECRETKEY')) EndFunc Func __MakeAPIRequest1($Session, $method = 'Get') ConsoleWrite('$_KEY: ' & $Session[0] & @crlf) ConsoleWrite('$_ENDPOINT: ' & $Session[1] & @crlf) ConsoleWrite('$_SECRETKEY: ' & $Session[2] & @crlf) EndFunc Func __MakeAPIRequest2($_KEY, $_ENDPOINT, $_SECRETKEY, $method = 'Get') ConsoleWrite('$_KEY: ' & $_KEY & @crlf) ConsoleWrite('$_ENDPOINT: ' & $_ENDPOINT & @crlf) ConsoleWrite('$_SECRETKEY: ' & $_SECRETKEY & @crlf) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __All_Global_A ; ======================================================================================== Func __All_Global_A($foo = -1) Local Enum $API_KEY = 0, $API_ENDPOINT, $API_SECRETKEY Local $ApiSecret[3] $ApiSecret[$API_KEY] = "___KEY___" $ApiSecret[$API_ENDPOINT] = "https://API_ENDPOINT.com/api" $ApiSecret[$API_SECRETKEY] = "A___SECRETKEY" If $foo = -1 Then Return $ApiSecret If IsString($foo) Then Return $ApiSecret[Execute($foo)] If $foo >= UBound($ApiSecret) Then Return SetError(1) Return $ApiSecret[$foo] EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __All_Global_B ; ======================================================================================== Func __All_Global_B($foo = -1) Local $o_SDist = ObjCreate( "Scripting.Dictionary" ) If Not IsObj($o_SDist) Then Return SetError(1) $o_SDist.Add('$API_KEY', '___KEY___') $o_SDist.Add('$API_ENDPOINT', 'https://API_ENDPOINT.com/api') $o_SDist.Add('$API_SECRETKEY', 'A___SECRETKEY') Local $ApiSecret If IsString($foo) Then $ApiSecret = $o_SDist.Item($foo) $o_SDist = 0 Return $ApiSecret EndIf $ApiSecret = $o_SDist.items() $o_SDist = 0 If $foo = -1 Then Return $ApiSecret If $foo >= UBound($ApiSecret) Then Return SetError(2) Return $ApiSecret[$foo] EndFunc
    1 point
  8. Isn't it a better idea to just attach the Au3 file for a long UDF?
    1 point
  9. Zedna

    Array to SQL Insert Command

    AutoIt's limits: https://www.autoitscript.com/autoit3/docs/appendix/LimitsDefaults.htm
    1 point
  10. jchd

    Array to SQL Insert Command

    For size, see Limits in AutoIt help and https://www.sqlite.org/search?s=d&q=limits for SQLite.
    1 point
  11. Hi @noellarkin. If it's just calling a function by name as string with parameters, you can also use the Call function.
    1 point
  12. This is made possible by AutoItSetOption("ExpandVarStrings", 1)
    1 point
  13. Even this works: Func _IncrementNumber($thisnumber) Return $thisnumber + 1 EndFunc Local $iNumber = 10 AutoItSetOption("ExpandVarStrings", 1) Local $iIncrementedNumber = Execute("_IncrementNumber($iNumber)") ConsoleWrite($iIncrementedNumber & @CRLF)
    1 point
  14. Execute takes any valid statement and executes it. Func _IncrementNumber($thisnumber) Return $thisnumber + 1 EndFunc Local $iNumber = 10 Local $iIncrementedNumber = Execute("_IncrementNumber(" & $iNumber & ")") ConsoleWrite($iIncrementedNumber & @CRLF)
    1 point
  15. noellarkin

    AutoIt Snippets

    yep you're right it makes a world of difference in terms of code readability, especially in conditional statements, especially for someone relatively new to coding (little over a year in). I have a whole bunch of small snippets just for readability: Func _ArrayEnd(ByRef $thisarray) Local $ReturnValue = 0 $ReturnValue = UBound($thisarray) - 1 Return $ReturnValue EndFunc Func _ArraySize(ByRef $thisarray) Local $ReturnValue = 0 $ReturnValue = UBound($thisarray) Return $ReturnValue EndFunc Func _ArrayDeleteFirstRow(ByRef $thisarray) _ArrayDelete($thisarray, 0) EndFunc Func _ArraySearchFound($arraysearchresult) Local $ReturnValue = 0 If $arraysearchresult <> -1 Then $ReturnValue = 1 Return $ReturnValue EndFunc Func _ArraySearchNotFound($arraysearchresult) Local $ReturnValue = 0 If $arraysearchresult = -1 Then $ReturnValue = 1 Return $ReturnValue EndFunc Func _ProcessExists($thisprocessid) Local $ReturnValue = 0 If $thisprocessid <> -1 Then $ReturnValue = 1 Return $ReturnValue EndFunc Func _ProcessDoesntExist($thisprocessid) Local $ReturnValue = 0 If $thisprocessid = -1 Then $ReturnValue = 1 Return $ReturnValue EndFunc etc etc :) oh and I know I have those extra lines $ReturnValue = 0 etc that's because I've been forcing myself to remember to use SESE whenever possible :)
    1 point
  16. SOLVE-SMART

    AutoIt Snippets

    Yes, why not @noellarkin ๐Ÿ‘ . I also like well defined names for variables, functions (methods), classes etc. As long as you and your team (in business cases) are fine with a consistent way of writing "clean code", at best defined by coding guidelines, all is good ๐Ÿ˜€ . Best regards Sven
    1 point
  17. noellarkin

    AutoIt Snippets

    Thanks! Yeah your example is a LOT more concise, of course I really like the use of ___ ? ___ : ___ - - I should use it more often in my scripts. On the other hand, I kinda like how functions names that are "natural language" look esp when in the context of conditionals. Example: If _StringDoesntContainSubstring($string, $substring) Then _________________ Else _________________ For me, if its more readable, I'd gladly deal with a few extra lines :)
    1 point
  18. My E4A matrix computing environment provides extensive support for simple and advanced statistics.
    1 point
  19. Standalone code: Opt("MustDeclareVars", 1) ;#include <String.au3> ;#include "WinHttp.au3" ; #INDEX# =================================================================================== ; Title ...............: _URL_Split ; Author... ...........: Dao Van Trong - TRONG.LIVE ; =========================================================================================== ; #CONSTANTS# =============================================================================== Global Const $hWINHTTPDLL__WINHTTP = DllOpen("winhttp.dll") DllOpen("winhttp.dll") ; making sure reference count never reaches 0 ;============================================================================================ Global $sURL_Input = 'https://Trong:Pa$$wo0d@files.trong.live:443/prv/test.jpg' Global $sURL_Protocol, $sURL_Protocol_Number, $sURL_Domain, $sURL_Port, $sURL_User, $sURL_Password, $sURL_FilePathName, $sURL_FilePATH, $sURL_FileName _URL_Split($sURL_Input, $sURL_Protocol, $sURL_Domain, $sURL_Port, $sURL_User, $sURL_Password, $sURL_FilePathName, $sURL_FilePATH, $sURL_FileName) ConsoleWrite("! URL : " & $sURL_Input & @CRLF) ConsoleWrite("+ _URL_GetDomain() > " & _URL_GetDomain($sURL_Input) & @CRLF) ConsoleWrite("+ _URL_Split() > " & @CRLF) ConsoleWrite("- Protocol : " & $sURL_Protocol & @CRLF) ConsoleWrite("- Domain : " & $sURL_Domain & @CRLF) ConsoleWrite("- Port : " & $sURL_Port & @CRLF) ConsoleWrite("- User : " & $sURL_User & @CRLF) ConsoleWrite("- Password : " & $sURL_Password & @CRLF) ConsoleWrite("- FilePathName: " & $sURL_FilePathName & @CRLF) ConsoleWrite("- FilePath : " & $sURL_FilePath & @CRLF) ConsoleWrite("- FileName : " & $sURL_FileName & @CRLF) Func _URL_Split($sURL_Input, ByRef $sURL_Protocol, ByRef $sURL_Domain, ByRef $sURL_Port, ByRef $sURL_User, ByRef $sURL_Password, ByRef $sURL_FilePathName, ByRef $sURL_FilePATH, ByRef $sURL_FileName) If StringStripWS($sURL_Input, 8) = '' Then Return SetError(1, 0, 0) $sURL_Input = StringReplace($sURL_Input, "\", "/") If (Not StringInStr($sURL_Input, '://')) Then $sURL_Input = 'http://' & $sURL_Input __URL_Split($sURL_Input, $sURL_Protocol, $sURL_Domain, $sURL_FilePATH, $sURL_FileName) StringReplace($sURL_Input, '@', '') If @extended > 1 Then Local $sUser, $aUser = _StringBetween($sURL_Input, $sURL_Protocol & "://", '@') If IsArray($aUser) Then $sUser = $aUser[0] $sURL_Input = StringReplace($sURL_Input, $sURL_Protocol & "://" & $sUser & '@', $sURL_Protocol & "://" & $sUser & '%40') EndIf EndIf Local $ORG_URL_Protocol = $sURL_Protocol, $sFake_Protocol = 'http', $iFake_Protocol = False Switch $sURL_Protocol Case 'http', 'https', 'ftp' Case Else $iFake_Protocol = True $sURL_Input = StringReplace($sURL_Input, $sURL_Protocol & "://", $sFake_Protocol & "://") EndSwitch Local $aUrl = _WinHttpCrackUrl($sURL_Input) If IsArray($aUrl) Then If $iFake_Protocol Then $sURL_Protocol = $ORG_URL_Protocol Else $sURL_Protocol = ($aUrl[0] == '' ? $sURL_Protocol : $aUrl[0]) EndIf ;$sURL_Protocol_Number = $aUrl[1] $sURL_Domain = ($aUrl[2] == '' ? $sURL_Domain : $aUrl[2]) $sURL_Port = $aUrl[3] $sURL_User = StringReplace($aUrl[4], '%40', '@') $sURL_Password = $aUrl[5] $sURL_FilePathName = ($aUrl[6] == '' ? $sURL_FilePATH & $sURL_FileName : $aUrl[6]) ;$sURL_ExtraInfo = $aUrl[7] Return $aUrl EndIf Return SetError(1, 0, "") EndFunc ;==>_URL_Split Func __URL_Split($sURL_Input, ByRef $sURL_Protocol, ByRef $sURL_Domain, ByRef $sURL_FilePATH, ByRef $sURL_FileName) Local $sURL_Protocol_Number_Pattern = '^(?s)(?i)(http|ftp|sftp|ftps|https|file)://(.*?/|.*$)(.*/){0,}(.*)$' Local $sURL_Pattern = "^(?i)(?:(?:[a-z]+):\/\/)?" & "(?:(?:(?:[^@:]+))" & "(?::(?:[^@]+))?@)?" & "([^\/:]+)" & "(?::(?:\d+))?" & "(?:\/(?:[^?]+)?)?" & "(?:\?\N+)?" Local $aURL_Pattern = StringRegExp($sURL_Input, $sURL_Protocol_Number_Pattern, 2) If Not IsArray($aURL_Pattern) Or UBound($aURL_Pattern) - 1 <> 4 Then Return SetError(1, 0, 0) If StringRight($aURL_Pattern[2], 1) = '/' Then $aURL_Pattern[2] = StringTrimRight($aURL_Pattern[2], 1) $aURL_Pattern[3] = '/' & $aURL_Pattern[3] EndIf $sURL_Protocol = $aURL_Pattern[1] Local $aHost = StringRegExp($sURL_Input, $sURL_Pattern, 1) If Not @error And IsArray($aHost) Then $sURL_Domain = $aHost[0] Else $sURL_Domain = $aURL_Pattern[2] EndIf $sURL_FilePATH = $aURL_Pattern[3] $sURL_FileName = $aURL_Pattern[4] Return $aURL_Pattern EndFunc ;==>__URL_Split Func _URL_GetDomain($sURL_Input) Local $sURL_Pattern = "^(?i)(?:(?:[a-z]+):\/\/)?" & _ ; Protocol "(?:(?:(?:[^@:]+))" & _ ; Username "(?::(?:[^@]+))?@)?" & _ ; Password "([^\/:]+)" & _ ; Host "(?::(?:\d+))?" & _ ; Port "(?:\/(?:[^?]+)?)?" & _ ; Path "(?:\?\N+)?" ; Query Local $aHost = StringRegExp($sURL_Input, $sURL_Pattern, 1) If IsArray($aHost) Then Return $aHost[0] Return "" EndFunc ;==>_URL_GetDomain Func _WinHttpCrackUrl($sURL, $iFlag = Default) __WinHttpDefault($iFlag, 0x80000000) Local $tURL_COMPONENTS = DllStructCreate("dword StructSize;" & "ptr SchemeName;" & "dword SchemeNameLength;" & "int Scheme;" & "ptr HostName;" & "dword HostNameLength;" & "word Port;" & "ptr UserName;" & "dword UserNameLength;" & "ptr Password;" & "dword PasswordLength;" & "ptr UrlPath;" & "dword UrlPathLength;" & "ptr ExtraInfo;" & "dword ExtraInfoLength") DllStructSetData($tURL_COMPONENTS, 1, DllStructGetSize($tURL_COMPONENTS)) Local $tBuffers[6] Local $iURLLen = StringLen($sURL) For $i = 0 To 5 $tBuffers[$i] = DllStructCreate("wchar[" & $iURLLen + 1 & "]") Next DllStructSetData($tURL_COMPONENTS, "SchemeNameLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "SchemeName", DllStructGetPtr($tBuffers[0])) DllStructSetData($tURL_COMPONENTS, "HostNameLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "HostName", DllStructGetPtr($tBuffers[1])) DllStructSetData($tURL_COMPONENTS, "UserNameLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "UserName", DllStructGetPtr($tBuffers[2])) DllStructSetData($tURL_COMPONENTS, "PasswordLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "Password", DllStructGetPtr($tBuffers[3])) DllStructSetData($tURL_COMPONENTS, "UrlPathLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "UrlPath", DllStructGetPtr($tBuffers[4])) DllStructSetData($tURL_COMPONENTS, "ExtraInfoLength", $iURLLen) DllStructSetData($tURL_COMPONENTS, "ExtraInfo", DllStructGetPtr($tBuffers[5])) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpCrackUrl", "wstr", $sURL, "dword", $iURLLen, "dword", $iFlag, "struct*", $tURL_COMPONENTS) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Local $aRet[8] = [DllStructGetData($tBuffers[0], 1), DllStructGetData($tURL_COMPONENTS, "Scheme"), DllStructGetData($tBuffers[1], 1), DllStructGetData($tURL_COMPONENTS, "Port"), DllStructGetData($tBuffers[2], 1), DllStructGetData($tBuffers[3], 1), DllStructGetData($tBuffers[4], 1), DllStructGetData($tBuffers[5], 1)] Return $aRet EndFunc ;==>_WinHttpCrackUrl Func __WinHttpDefault(ByRef $vInput, $vOutput) If $vInput = Default Or Number($vInput) = -1 Then $vInput = $vOutput EndFunc ;==>__WinHttpDefault Func _StringBetween($sString, $sStart, $sEnd, $iMode = 0, $bCase = False) $sStart = $sStart ? "\Q" & $sStart & "\E" : "\A" If $iMode <> 1 Then $iMode = 0 If $iMode = 0 Then $sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z" Else $sEnd = $sEnd ? "\Q" & $sEnd & "\E" : "\z" EndIf If $bCase = Default Then $bCase = False EndIf Local $aRet = StringRegExp($sString, "(?s" & (Not $bCase ? "i" : "") & ")" & $sStart & "(.*?)" & $sEnd, 3) If @error Then Return SetError(1, 0, 0) Return $aRet EndFunc ;==>_StringBetween ;Dao Van Trong - TRONG.LIVE
    1 point
  20. This is what I was trying to do, thanks to all the friends who helped, with the help of the dear friends I can now adjust the script for my project. But once thanks @SOLVE-SMART, @Nine, @Dan_555, @jugador, @Gianni.
    1 point
  21. funny question @mutleey Here's my 2 cents the keys on the first row of the virtual keyboard are spare, as you click on the keys, the list of elements is reduced and the disallowed keys are inhibited The key to the right of the M key, ( โ—„ ) deletes the last character in the input field the key ( ยถ ) confirms the text present in the input field p.s. my "graphics keyboard" is a bit spartan, but take this script as one more possible way to achieve your goal #include <GUIConstants.au3> Global $aList = _GetCities() ; create the 1D array MsgBox(0, 'Result', 'You chose ' & _Example($aList, 'choose a city')) ; Pass a 1D array with a list of entries to choose from Func _Example(ByRef $asKeyWords, $sTitle = '') ; 00000000001111111111222222222233333333334444444444 ; 01234567890123456789012345678901234567890123456789 Local Static $aKeys = StringSplit('โ˜บโ˜ป♥♦♣♠•โ—˜โ™ชโ™ซ1234567890QWERTYUIOPASDFGHJKL ZXCVBNMโ—„ ¶', '', 2) Local Static $aToggleableKey = StringSplit('00000000001111111111111111111111111111111111111000', '', 2) Local $aMyMatrix[UBound($aKeys)] Local $sString, $hInput, $hList, $bFlag Local $sPartialInp, $iPartialLen, $sAllowed, $iNumRows, $sReturn $hGUI = GUICreate($sTitle, 401, 600) $hInput = GUICtrlCreateInput("", 5, 5, 392, 20, $ES_READONLY) ; 0x0800 ) GUICtrlSetBkColor(-1, 0XFFFFFF) ; Virtual Custom Keyboard Local $xPanelPos = 0, $yPanelPos = 30, $nrPerLine = 10, $nrOfLines = 5, $ctrlWidth = 39, $ctrlHeight = 39, $xSpace = 1, $ySpace = 1, $xBorder = 1, $yBorder = 1, $style = -1, $exStyle = -1 For $i = 0 To $nrPerLine * $nrOfLines - 1 ; coordinates 1 based $col = Mod($i, $nrPerLine) + 1 ; Horizontal position within the grid (column) $row = Int($i / $nrPerLine) + 1 ; Vertical position within the grid (row) $left = $xPanelPos + ((($ctrlWidth + $xSpace) * $col) - $xSpace) - $ctrlWidth + $xBorder $top = $yPanelPos + ((($ctrlHeight + $ySpace) * $row) - $ySpace) - $ctrlHeight + $yBorder $text = $aKeys[$i] ; + 1 ; "*" ; "." ; "(*)" ; create the control(s) $aMyMatrix[$i] = GUICtrlCreateButton($text, $left, $top, $ctrlWidth, $ctrlHeight, $style, $exStyle) Next $hList = GUICtrlCreateList('', 1, 233, 400, 370, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL)) GUICtrlSetFont(-1, 12, 0, 0, 'Courier New') For $i = 0 To UBound($asKeyWords) - 1 GUICtrlSetData($hList, $asKeyWords[$i]) Next GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE $sReturn = GUICtrlRead($hInput) GUIDelete($hGUI) Return $sReturn Case $hList GUICtrlSetData($hInput, GUICtrlRead($hList)) EndSwitch If $bFlag Then $bFlag = False $sPartialInp = GUICtrlRead($hInput) $iPartialLen = StringLen($sPartialInp) ; empty the list GUICtrlSetData($hList, "") $iNumRows = 0 ; refill the list $sAllowed = "" For $i = 0 To UBound($asKeyWords) - 1 If StringLeft($asKeyWords[$i], $iPartialLen) = $sPartialInp Then GUICtrlSetData($hList, $asKeyWords[$i]) $iNumRows += 1 $sAllowed &= StringMid($asKeyWords[$i], $iPartialLen + 1, 1) EndIf Next ; enable or disable keys For $i = 0 To UBound($aKeys) - 1 If $aToggleableKey[$i] = "1" Then If StringInStr($sAllowed, $aKeys[$i]) Then GUICtrlSetState($aMyMatrix[$i], 64) ; $GUI_ENABLE (64) Control will be enabled. Else GUICtrlSetState($aMyMatrix[$i], 128) ; $GUI_DISABLE (128) Control will be greyed out. EndIf EndIf Next EndIf ; 00000000001111111111222222222233333333334444444444 ; 01234567890123456789012345678901234567890123456789 ; โ˜บโ˜ป♥♦♣♠•โ—˜โ™ชโ™ซ1234567890QWERTYUIOPASDFGHJKL ZXCVBNMโ—„ ¶ ; ; check if and which key was pressed ; and manage actions to be taken accordingly For $iKey = 0 To UBound($aMyMatrix) - 1 If $Msg = $aMyMatrix[$iKey] Then Switch $iKey Case 0 To 7 ConsoleWrite("Debug: Spare key" & @CRLF) Case 8 Beep(500, 70) Case 9 Beep(750, 70) Beep(500, 70) Case 47 ; delete rightmost char GUICtrlSetData($hInput, StringTrimRight(GUICtrlRead($hInput), 1)) Case 48 ConsoleWrite("Debug: Spare key" & @CRLF) Case 49 ; return virtual key ¶ ; If $iNumRows = 1 Then $sReturn = GUICtrlRead($hInput) GUIDelete($hGUI) Return $sReturn ; EndIf Case 10 To 46 ; numbers, letters, space GUICtrlSetData($hInput, GUICtrlRead($hInput) & $aKeys[$iKey]) EndSwitch EndIf Next If $sString <> GUICtrlRead($hInput) Then $sString = GUICtrlRead($hInput) $bFlag = True EndIf WEnd EndFunc ;==>_Example Func _GetCities() ; source: https://simplemaps.com/data/world-cities ; ---------------------------------------- ; here a reduced list of the top 159 most populous cities ; (for fun I also added my little town (Imperia) just to have a total of 160 cities) Local $sCities = '' $sCities &= "Tokyo,New York,Mexico City,Mumbai,Sao Paulo,Delhi,Shanghai,Kolkata,Los Angeles,Dhaka,Buenos Aires,Karachi,Cairo,Rio de Janeiro,Osaka,Beijing," $sCities &= "Manila,Moscow,Istanbul,Paris,Seoul,Lagos,Jakarta,Guangzhou,Chicago,London,Lima,Tehran,Kinshasa,Bogota,Shenzhen,Wuhan," $sCities &= "Hong Kong,Tianjin,Chennai,Taipei,Bangalore,Bangkok,Lahore,Chongqing,Miami,Hyderabad,Dallas,Santiago,Philadelphia,Belo Horizonte,Madrid,Houston," $sCities &= "Ahmedabad,Ho Chi Minh City,Washington,Atlanta,Toronto,Singapore,Luanda,Baghdad,Barcelona,Haora,Shenyeng,Khartoum,Pune,Boston,Sydney,St. Petersburg," $sCities &= "Chittagong,Dongguan,Riyadh,Hanoi,Guadalajara,Melbourne,Alexandria,Chengdu,Rangoon,Phoenix,Xian,Porto Alegre,Surat,Hechi,Abidjan,Brasilia," $sCities &= "Ankara,Monterrey,Yokohama,Nanjing,Montreal,Guiyang,Recife,Seattle,Harbin,San Francisco,Fortaleza,Zhangzhou,Detroit,Salvador,Busan,Johannesburg," $sCities &= "Berlin,Algiers,Rome,Pyongyang,Medellin,Kabul,Athens,Nagoya,Cape Town,San Diego,Changchun,Casablanca,Dalian,Kanpur,Kano,Tel Aviv-Yafo," $sCities &= "Addis Ababa,Curitiba,Zibo,Jeddah,Nairobi,Hangzhou,Benoni,Caracas,Milan,Stuttgart,Kunming,Dar es Salaam,Minneapolis,Jaipur,Taiyuan,Frankfurt," $sCities &= "Qingdao,Surabaya,Lisbon,Tampa,Jinan,Fukuoka,Campinas,Denver,Kaohsiung,Quezon City,Katowice,Aleppo,Durban,Kiev,Lucknow,El Giza," $sCities &= "Zhengzhou,Taichung,Brooklyn,Ibadan,Faisalabad,Fuzhou,Dakar,Changsha,Izmir,Xiangtan,Lanzhou,Incheon,Sapporo,Xiamen,Guayaquil,Imperia" Return StringSplit($sCities, ',', 2) ; $STR_NOCOUNT (2) = disable the return count in the first element EndFunc ;==>_GetCities
    1 point
  22. Musashi

    Stringleft and Array

    Or : #include <array.au3> Local $aArray = [111111111, 2222222222, 3333333333] _ArrayDisplay($aArray) For $i = 0 To UBound ($aArray) -1 Step 1 $aArray[$i] = StringLeft($aArray[$i] , 3) Next _ArrayDisplay($aArray)
    1 point
  23. Compiled VB.NET code Since the source files for virtual treeviews are large files, it's advantageous and necessary to handle the files with compiled code. This post is about compiled VB.NET code. All code is located in the folder Examples\Part 2\2) Compiled VB.NET Code. Using VB.NET code Compiled VB.NET methods can be executed in AutoIt scripts through the DotNetAll.au3 UDF. Here the VB.NET code is loaded with the function TVSourceCreateVbNetCodeObject(): ; Create $oVbNetCode object ; Executes treeview source file functions as compiled VB.NET code ; ; Error code in @error Return value ; 1 -> Failed to locate TVSourceFile.vb Success -> 1 or $oVbNetCode ; 2 -> Failed to create $oVbNetCode object Failure -> 0 ; Func TVSourceCreateVbNetCodeObject( _ $sVbNetCodePath = "" ) ; Relative path to VB.NET source code file ; VB.NET source code is saved in Includes\TVSourceFile.vb ; The path to set is the relative path from the running script to this file Local Static $bVbNetCodeObject = 0, $oNetCode, $oVbNetCode If Not $sVbNetCodePath And $bVbNetCodeObject Then Return $oVbNetCode ; Locate TVSourceFile.vb If Not FileExists( $sVbNetCodePath ) Then Return SetError( 1, 0, 0 ) ; Create $oVbNetCode object $oNetCode = DotNet_LoadVBcode( FileRead( $sVbNetCodePath ), "System.dll" ) $oVbNetCode = DotNet_CreateObject( $oNetCode, "TVSourceFile" ) If Not IsObj( $oVbNetCode ) Then Return SetError( 2, 0, 0 ) $bVbNetCodeObject = 1 Return 1 EndFunc The first function call is an initialization, where the path to the VB.NET code is specified as a parameter, and where $oVbNetCode is created and stored as a local static variable in the function. A lot of AutoIt code is executed to create the $oVbNetCode object. Therefore, it's performance-optimizing to create the object only once during an initialization. The $oVbNetCode object is created at the top of a script this way: If Not TVSourceCreateVbNetCodeObject( "..\Includes\TVSourceFile.vb" ) Then ConsoleWrite( "TVSourceCreateVbNetCodeObject: @error = " & @error & @CRLF ) Exit 1 EndIf ..\Includes\TVSourceFile.vb contains the VB.NET code. In subsequent function calls without a path parameter, the stored $oVbNetCode object is returned. TVSourceFile.au3 (Includes\TVSourceFile.au3) This is the updated function list at top of file: ; Functions ; ----------------------------------- ; TVSourceCreatePlain() Create random plain source file for non-virtual treeview ; TVSourceCreatePlainDbg() Create random plain source file for non-virtual treeview. Debug version. ; TVSourceCreatePlainEx() Based on recursive function with support for 100 levels ; TVSourceCreatePlainExVb() Based on recursive function with support for 100 levels. VB.NET code. ; TVSourceCreatePlainExDbg() Based on recursive function with support for 100 levels. Debug version. ; TVSourceCreatePlainExDbgVb() Based on recursive function with support for 100 levels. Debug version. VB.NET code. ; TVSourceCreatePlainExConst() Create constant plain source file for non-virtual treeview. Debug version. Constant source file. ; TVSourceCreatePlainExConstVb() Create constant plain source file for non-virtual treeview. Debug version. Constant source file. VB.NET code. ; TVSourceCreatePlainExConstCount() Count number of treeview items generated by TVSourceCreatePlainExConst/Vb() above ; TVSourceCreatePlainExConstCountVb() Count number of treeview items generated by TVSourceCreatePlainExConst/Vb() above. VB.NET code. ; TVSourceCreateVirtual() Create random source file for virtual treeview ; TVSourceCreateVirtualDbg() Create random source file for virtual treeview. Debug version. Contains code comments. <<<<<<<<<< ; ; TVSourceConvertPlainToVirtual() Convert plain source file for non-virtual treeview to source file for virtual treeview ; TVSourceConvertPlainToVirtualVb() Convert plain source file for non-virtual treeview to source file for virtual treeview. VB.NET code. ; TVSourceConvertVirtualToPlain() Convert source file for virtual treeview to plain source file for non-virtual treeview ; ; TVSourceDisplayPlain() Display non-virtual treeview from plain source file ; TVSourceDisplayVirtual() Display virtual treeview from source file TVSourceFile.vb (Includes\TVSourceFile.vb) TVSourceFile.vb contains all the VB.NET code. You may take a closer look at the code yourself if you are interested. These are a few general considerations. When the VB.NET code is executed, a syntax check comparable to Au3Check is performed. If the AutoIt script is executed in SciTE, the syntax errors are displayed in the console. A runtime error will usually appear like this in the console: TVSourceFile.au3 (1323) : ==> The requested action with this object has failed: Local $iRet = $oVbNetCode.TVSourceConvertPlainToVirtualVb( $iLevels, $sTVPlainSrc, $sTVVirtualSrc ) Local $iRet = $oVbNetCode^ ERROR Several VB.NET features are used in the code, e.g. Files, Arrays, Lists, Dictionary objects, Recursive functions and Regular expressions. Also note that AutoIt code can be translated relatively directly and easily into VB.NET code. Examples (Examples\5) TVSourceConvertPlainToVirtualVb.au3) The Examples\ folder contains an example for each of the 5 functions implemented in VB.NET code. Run the examples in SciTE with F5. Treeview source files are stored in the Sources\ top folder. This is a closer look at example 5) TVSourceConvertPlainToVirtualVb.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include "..\Includes\TVSourceFile.au3" If Not TVSourceCreateVbNetCodeObject( "..\Includes\TVSourceFile.vb" ) Then ConsoleWrite( "TVSourceCreateVbNetCodeObject: @error = " & @error & @CRLF ) Exit 1 EndIf Example( 6, 16, 4, 104284 ) ; 104,284 treeview items ;Example( 5, 81, 9, 1012329 ) ; 1,012,329 treeview items Func Example( $iLevels, $iItems0, $iMultiplier, $iCount ) Local $sSources = "..\..\..\..\Sources\" & $iLevels & " levels, " & $iCount & " items, " ConsoleWrite( "TVSourceCreatePlainExConstVb( " & $sSources & "Plain, debug.txt" & " ) Creating..." & @CRLF ) If TVSourceCreatePlainExConstVb( $iLevels, $iItems0, $iMultiplier, $sSources & "Plain, debug.txt" ) Then ConsoleWrite( "TVSourceConvertPlainToVirtualVb( " & $sSources & "Plain, debug.txt" & " ) Converting..." & @CRLF ) If TVSourceConvertPlainToVirtualVb( $iLevels, $sSources & "Plain, debug.txt", $sSources & "Virtual, debug.txt" ) Then ConsoleWrite( "TVSourceDisplayVirtual( " & $sSources & "Virtual, debug.txt" & " ) Displaying..." & @CRLF ) If Not TVSourceDisplayVirtual( $sSources & "Virtual, debug.txt" ) Then _ Return ConsoleWrite( "TVSourceDisplayVirtual: @error = " & @error & @CRLF ) Else Return ConsoleWrite( "TVSourceConvertPlainToVirtualVb: @error = " & @error & @CRLF ) EndIf Else Return ConsoleWrite( "TVSourceCreatePlainExConstVb: @error = " & @error & @CRLF ) EndIf EndFunc Notice how TVSourceCreateVbNetCodeObject() is initialized in the top part of the code. TVSourceConvertPlainToVirtualVb() is called in the middle of the function: ; Convert plain source file for non-virtual treeview to source file for virtual treeview. VB.NET code. ; ; Error code in @error Return value ; 1 -> Invalid $iLevels value Success -> 1 ; 2 -> Plain source file doesn't exist Failure -> 0 ; 3 -> Invalid or empty $aSource array ; 4 -> Invalid source file item format ; 5 -> Too many treeview elements ; 6 -> Couldn't get $oVbNetCode ; ; Errors 3 - 5 comes from TVSourceConvertPlainToVirtualVb() in TVSourceFile.vb ; Func TVSourceConvertPlainToVirtualVb( _ $iLevels, _ ; Treeview levels, 2 <= $iLevels <= 100 $sTVPlainSrc, _ ; Name of plain treeview input source file $sTVVirtualSrc ) ; Name of virtual treeview output source file If Not ( 2 <= $iLevels And $iLevels <= 100 ) Then Return SetError( 1, 0, 0 ) If Not FileExists( $sTVPlainSrc ) Then Return SetError( 2, 0, 0 ) ; Get $oVbNetCode object to execute function as compiled VB.NET code Local $oVbNetCode = TVSourceCreateVbNetCodeObject() If Not IsObj( $oVbNetCode ) Then Return SetError( 6, 0, 0 ) ; Execute TVSourceConvertPlainToVirtualVb() as compiled VB.NET code Local $iRet = $oVbNetCode.TVSourceConvertPlainToVirtualVb( $iLevels, $sTVPlainSrc, $sTVVirtualSrc ) If $iRet < 0 Then Return SetError( -$iRet+2, 0, 0 ) Return 1 EndFunc Notice again how TVSourceCreateVbNetCodeObject() is now called without a parameter. Also note that the name of the VB.NET method is the same as the name of the AutoIt function. New 7z-file at bottom of first post.
    1 point
  24. SOLVE-SMART

    AutoIt Snippets

    Hi @noellarkin, regarding readability I like to agree with you. Custom wrapper function are often a good way to represent what is actually going on in a function. In your snippet for the StringInStr functions, I would say it's not necessary to have two separate functions. Why not just like that: Func _StringContains($sString, $sSubstring) Return (StringInStr($sString, $sSubstring) <> 0) ? True : False EndFunc ConsoleWrite( _StringContains('This is a simple test.', 'simple') & @CRLF) ConsoleWrite(Not _StringContains('This is a simple test.', 'simple') & @CRLF) Anyhow, thanks for sharing some code snippets ๐Ÿ‘ . Best regardsSven________________Stay innovative!
    1 point
  25. I stumbled across this recent support thread on using multiple "stopwatches", so I thought I would have a little fun and make a full-featured stopwatch object using AutoItObject_Internal.au3 by @genius257. It's not super useful, but who doesn't like a full UDF for the simplest of tasks? This is more of a proof of concept and is not meant to be extremely accurate or reliable, but I'm still open to suggestions if anyone has any ideas for improvement. The stopwatch has the following methods: start: start (or restart) the timer and reset the accumulated timer value stop: stop/pause the timer lap: return the time since the last time lap was called or since the timer was started reset: stop and reset the timer elapsed: get the time since the last reset or since the timer was started To use a stopwatch, simply create a new object and start the timer. You can then retrieve the total elapsed time or the current lap time. #include "ObjStopwatch.au3" $oStopwatch1 = _ObjStopwatch() $oStopwatch1.start() sleep(500) consolewrite("Lap time: " & $oStopwatch1.lap() & @CRLF) sleep(500) consolewrite("Total time: " & $oStopwatch1.elapsed() & @CRLF) The .elapsed method has 1 optional parameter to set the return formatting. ; Syntax.........: _ObjStopwatch_elapsed ( [$iFormat = 0] ) ; Parameters ....: $iFormat = desired format ; - 0 = ms with decimal (same as TimerDiff()) ; - 1 = hh:mm:ss ; - 2 = hh:mm:ss:0ms ; - 3 = hh:mm:ss.0 Similarly, the .lap method has 2 optional parameters. By passing False as the 2nd parameter, you can poll the current lap time without triggering a new lap. ; Syntax.........: _ObjStopwatch_lap ( [ $iFormat = 0 [, $bNewLap = True ]] ) ; Parameters ....: $iFormat = desired format ; - 0 = ms with decimal (same as TimerDiff()) ; - 1 = hh:mm:ss ; - 2 = hh:mm:ss:0ms ; - 3 = hh:mm:ss.0 ; $bNewLap = Return the current lap time, and reset lap timer The real power of this UDF (really all thanks for AutoItObject_Internal) is the ability to create as many Stopwatch objects as you want, which you are then free to start and stop independently. #include "ObjStopwatch.au3" $oStopwatch1 = _ObjStopwatch() $oStopwatch2 = _ObjStopwatch() $oStopwatch3 = _ObjStopwatch() $oStopwatch4 = _ObjStopwatch() $oStopwatch1.start() $oStopwatch2.start() Sleep(500) $oStopwatch1.stop() Sleep(500) consolewrite("Stopwatch 1: " & $oStopwatch1.elapsed() & @CRLF) consolewrite("Stopwatch 2: " & $oStopwatch2.elapsed() & @CRLF) Lastly, here is a simple GUI example for recording the lap times of 2 different stopwatches. Updated 2022-08-29: ObjStopwatch.au3 Fixed time formatting issue. Prerequisite: AutoItObject_Internal.au3 is required. Download [HERE].
    1 point
  26. Version 0.1.0

    810 downloads

    ATTENTION! THIS IS STILL WORK IN PROGRESS! This is the modified version of MrCreatoR's "Simple Library Docs Generator". It allows to create CHM help files that look like the AutoIt help file. In additon this CHM files can then be used with Advanced.Help. This a very early alpha version - so it is miles away from being perfect. It's just something for you to play with. The documentation is in the making and will be published as soon as possible. BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    1 point
  27. #include <WinAPIShellEx.au3> $s_Path_Downloads = _WinAPI_ShellGetKnownFolderPath($FOLDERID_Downloads) MsgBox(0,"", $s_Path_Downloads)
    1 point
×
×
  • Create New...