Spider001 Posted October 16, 2014 Share Posted October 16, 2014 hey What happen to #include "WinHTTP.au3" ? I try to download a file and i dont now the name. https://addons.mozilla.org/firefox/downloads/latest/231203/addon-231203-latest.xpi?src=dp-btn-primary Thank you Link to comment Share on other sites More sharing options...
kylomas Posted October 16, 2014 Share Posted October 16, 2014 hey, Look up the syntax for #include. That should give you a hint. Your Welcome, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Spider001 Posted October 16, 2014 Author Share Posted October 16, 2014 found the .au3 files https://code.google.com/p/autoit-winhttp/downloads/list but still can't retrive the filename Link to comment Share on other sites More sharing options...
kylomas Posted October 16, 2014 Share Posted October 16, 2014 Download / extract the file and put it wherever you run your script from... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Solution trancexx Posted October 16, 2014 Solution Share Posted October 16, 2014 kylomas, he means something else. Spider one, you can do it like this: expandcollapse popup#include "WinHttp.au3" Global Const $sDomain = "https://addons.mozilla.org" Global $sPage = "firefox/downloads/latest/231203/addon-231203-latest.xpi?src=dp-btn-primary" Global $sFileName = StringRegExpReplace($sPage, ".*/", "") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $sFileContent = GetTheFileContent($sFileName) ConsoleWrite($sFileName & @CRLF) MsgBox(4096, "File Name", $sFileName) ; See what's returned (it's ZIP format so you'll see only first few characters in messagebox) MsgBox(4096, "Content", $sFileContent) ; The End ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func GetTheFileContent(ByRef $sWEB_FileName) ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Get connection handle Local $hConnect = _WinHttpConnect($hOpen, $sDomain) ; Register Callback function Local Const $hREDIRECT_CALLBACK = DllCallbackRegister(__RedirectFunc, "none", "handle;dword_ptr;dword;ptr;dword") ; Set callback _WinHttpSetStatusCallback($hConnect, $hREDIRECT_CALLBACK, $WINHTTP_CALLBACK_FLAG_REDIRECT) Local $hRequest = _WinHttpSimpleSendSSLRequest($hConnect, Default, $sPage) ; Get content disposition Local $sDispositionFileName = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_DISPOSITION) ; Check if file name is specified inside the header If $sDispositionFileName Then $sWEB_FileName = StringReplace(StringRegExpReplace($sDispositionFileName, 'attachment.*=', ""), '"', "") ; Read file Local $sReturned = _WinHttpSimpleReadData($hRequest) ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Free callback DllCallbackFree($hREDIRECT_CALLBACK) ; All done Return $sReturned EndFunc ; Define callback function Func __RedirectFunc($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength) Local $sStatus = DllStructGetData(DllStructCreate("wchar[" & $iStatusInformationLength & "]", $pStatusInformation), 1) Dim $sFileName = StringRegExpReplace($sStatus, ".*/", "") EndFunc Spider001 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Spider001 Posted October 16, 2014 Author Share Posted October 16, 2014 Thanks trancexx thats exactly what i need looking for that the whole day Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now