Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/15/2019 in all areas

  1. https://ss64.com/ps/ is one of my favorite sites with explanation of powershell. Just type ise in windows start and you get the ps cmd editor and experiment. Powershell is the mainstream language for windows. For your problem I just feel ps suits better then AutoIt but both can do what you want.
    2 points
  2. jchd

    With...EndWith

    How does that relate to the post title?
    1 point
  3. share the code and let's have a look-see, as mentioned above
    1 point
  4. You would have to post the code really
    1 point
  5. #include "WinHttp.au3" #include <array.au3> Global $array1[5] $array1[0] = "https://vorboss.dl.sourceforge.net/project/orwelldevcpp/Setup%20Releases/Dev-Cpp%205.11%20TDM-GCC%204.9.2%20Setup.exe" $array1[1] = "https://web.archive.org/web/20190730142339if_/https://github-production-release-asset-2e65be.s3.amazonaws.com/67031040/eb6ad800-a8f2-11e8-9ab0-042afa1a979a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190730%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190730T142323Z&X-Amz-Expires=300&X-Amz-Signature=c64ccf4eae74a747e79c4f26524722842d6c1e9eba71605b20c4fc0406c11933&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dupx-3.95-win32.zip&response-content-type=application%2Foctet-stream" $array1[2] = "https://www.grigsoft.com/wincmp-setup.zip" $array1[3] = "https://codeload.github.com/dragana-r/autoit-winhttp/zip/1.6.4.1" $array1[4] = "https://www.7-zip.org/a/7z1900-x64.exe" For $i = 0 To UBound($array1) - 1 $aCracked = _WinHttpCrackUrl($array1[$i]) ; _ArrayDisplay($aCracked) $hHttpOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hHttpOpen, $aCracked[2], $aCracked[3]) $hRequest = _WinHttpOpenRequest($hConnect, "GET", $aCracked[6] & $aCracked[7], Default, Default, Default, $WINHTTP_FLAG_SECURE) _WinHttpAddRequestHeaders($hRequest, "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0") _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) $sDisp = _WinHttpQueryHeaders($hRequest) ; ConsoleWrite($sDisp & @CRLF) Local $sFilename If StringInStr($sDisp, 'Content-Disposition: attachment; filename=') Then $aDisp = StringSplit($sDisp, @CRLF) For $y = 1 To $aDisp[0] If StringInStr($aDisp[$y], 'Content-Disposition: attachment; filename=') Then $sFilename = StringReplace($aDisp[$y], 'Content-Disposition: attachment; filename=', '') ExitLoop EndIf Next ElseIf StringInStr($sDisp, 'Location: ') Then $aDisp = StringSplit($sDisp, @CRLF) For $y = 1 To $aDisp[0] If StringInStr($aDisp[$y], 'Location: ') Then $sFilename = StringReplace($aDisp[$y], 'Location: ', '') $sFilename = StringRight($sFilename, StringLen($sFilename) - StringInStr($sFilename, "/", 0, -1)) ExitLoop EndIf Next Else $sFilename = StringRight($aCracked[6], StringLen($aCracked[6]) - StringInStr($aCracked[6], "/", 0, -1)) EndIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hHttpOpen) MsgBox(0, "", "URL=" & @CRLF & $array1[$i] & @CRLF & @CRLF & "Filename=" & @CRLF & $sFilename) Next
    1 point
  6. ok just had another look, think i understood now maybe something like this should work ? you will need to add all cases for numbers perfixed with "%" like Chr(37) & "3" and all file types you need to grab in #include <File.au3> Global $array1[4] = ["https://vorboss.dl.sourceforge.net/project/orwelldevcpp/Setup%20Releases/Dev-Cpp%205.11%20TDM-GCC%204.9.2%20Setup.exe" & @CRLF & _ "https://web.archive.org/web/20190730142339if_/https://github-production-release-asset-2e65be.s3.amazonaws.com/67031040/eb6ad800-a8f2-11e8-9ab0-042afa1a979a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190730%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190730T142323Z&X-Amz-Expires=300&X-Amz-Signature=c64ccf4eae74a747e79c4f26524722842d6c1e9eba71605b20c4fc0406c11933&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dupx-3.95-win32.zip&response-content-type=application%2Foctet-stream" & @CRLF & _ "https://www.grigsoft.com/wincmp-setup.zip" & @CRLF & _ "https://codeload.github.com/dragana-r/autoit-winhttp/zip/1.6.4.1" & @CRLF & _ "https://www.7-zip.org/a/7z1900-x64.exe"] $types = "(?=.exe|.zip)" For $i = 0 To UBound($array1) - 1 $ReadUrl = StringRegExp($array1[$i], "[\w -.%]+" & $types & "\.\w{3}", 3) For $j = 0 To UBound($ReadUrl) - 1 If StringInStr($ReadUrl[$j], Chr(37) & "3") Then $ReadUrl[$j] = StringTrimLeft($ReadUrl[$j], StringInStr($ReadUrl[$j], Chr(37) & "3", 0, -1) + 1) EndIf $ReadUrl[$j] = StringReplace($ReadUrl[$j], Chr(37) & "20", "") Next _ArrayDisplay($ReadUrl) Next
    1 point
  7. This thread may provide some insight.
    1 point
  8. You can reference the content of an array by using brackets at the end of the array, and the index of the desired element. For example $aArrayVariableName[0] would reference the string "WIN2K16" in your array above (using the correct array variable name of course). This article should tell you everything you need to know about Arrays. https://www.autoitscript.com/wiki/Arrays Let us know if you have questions. Just as a recommendation. I find it useful to use Constants to collect info from arrays to make it easier to read the source, and you don't have to keep track of what index numbers represent the contents of an array. This also depends on the accuracy of the array being produced, but additional error checking/logic should help rule out anomalies. #include <Array.au3> Const Enum $DB_HOSTNAME, $DB_NAME, $DB_FIELD, $DB_PORT Local $aTest[4]=['WIN2K16','ePO_WIN2K16','',1433] Local $db_ServerName = $aTest[$DB_HOSTNAME] Local $db_DatabaseName = $aTest[$DB_NAME] Local $db_DatabasePort = $aTest[$DB_PORT] Msgbox(0,"DB Info",$db_ServerName & @CRLF & $db_DatabaseName & @CRLF & $db_DatabasePort) Also, depending on your situation, you may not need to go through the work of creating variables which duplicate the values in the array. Up to you and your needs.
    1 point
  9. So as Kafu said and as you mentioned in post #1, get the headers Personally as soon as it begins to be tricky with redirections and so on, I use Curl which makes the whole job for me #include <AutoItConstants.au3> $link = "https://codeload.github.com/dragana-r/autoit-winhttp/zip/1.6.4.1" Local $iPID = Run("curl -Lsk --head " & $link, "", @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $filename = StringRegExpReplace(StdoutRead($iPID), '(?s).*filename=(\S+).*', '$1') ConsoleWrite($filename & @crlf) To visualize the headers, ConsoleWrite on StdoutRead
    1 point
  10. iamtheky

    Illegal characters

    Im taking a swing. The problem is that you copy and pasted this "With IPconfig /all you can also find out your DNS server and MAC Address" from a website and picked up some unwanted zero-space html characters. Copy your text into notepad or something that discards those characters, and then into Scite, or type it manually and you would not experience this issue. edit: or hit backspace at the end of the word MAC and the end of the word ALL and I bet the cursor doesnt move but a character gets deleted.
    1 point
×
×
  • Create New...