Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/02/2018 in all areas

  1. Hi Tersion, I made little changes in your script, hope you'll like that. #include <InetConstants.au3> Global $URLsite = "http://download.blender.org/peach/bigbuckbunny_movies/" Global $aFileName[1+3] = ["", "BigBuckBunny_320x180.mp4", _ "BigBuckBunny_640x360.m4v", "big_buck_bunny_720p_stereo.ogg"] ; 1+3 to get rid of [0] Global $hDownload[1+3], $iStep = 0 For $i = 1 To 3 $hDownload[$i] = InetGet($URLsite & $aFileName[$i], @ScriptDir & "\" & $aFileName[$i], _ $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Next Sleep(5000) For $i = 1 To 3 ConsoleWrite("Download " & $i & ": " & InetGetInfo($hDownload[$i], $INET_DOWNLOADREAD)/1024 & _ "KB while downloaded and still ongoing..." & @CRLF) Next Do For $i = 1 To 3 If InetGetInfo($hDownload[$i], $INET_DOWNLOADREAD) == 0 Then ConsoleWrite("Waiting - $hDownload_" & $i & " is closing!" & @CRLF) $iTimer = TimerInit() InetClose($hDownload[$i]) ConsoleWrite("It took: " & Round(TimerDiff($iTimer)) & "ms to close" & @CRLF) ExitLoop EndIf Next ConsoleWrite($iStep & @CRLF) Sleep(1000) $iStep += 1 Until $iStep == 10 For $i = 1 To 3 InetClose($hDownload[$i]) FileDelete(@ScriptDir & "\" & $aFileName[$i]) Next I'm not sure there is a valid handle for your empty download, because if you change one line of your script from : InetClose($hDownload[$i]) to $Result = InetClose($hDownload[$i]) MsgBox(0, "", "$Result = " & $Result) You will see MsgBox displaying "False", which should mean the Handle isn't "found and closed" for your empty download, so maybe the InetClose() function shouldn't be used when your download returns 0 bytes (?) Also look at the example in the help file, topic InetGetInfo : ; part of the online example, topic InetGetInfo : ; ... ; Retrieve details about the download file. Local $aData = InetGetInfo($hDownload) If @error Then FileDelete($sFilePath) Return False ; If an error occurred then return from the function and delete the file. EndIf ; Close the handle returned by InetGet. InetClose($hDownload) ; ... Why the handle was not closed in the example when something went wrong ? Also I'm not a big fan of the "==" in your script, at this line : If InetGetInfo($hDownload[$i], $INET_DOWNLOADREAD) == 0 I thought "==" was used to compare two strings if they are equal and case-sensitive. Now when we change "==" to a simple "=" all the ConsoleWrite is different lol Hope other readers will share their thoughts with you about your script
    2 points
  2. Hi all, Please read this announcement to understand why this thread is now locked. I realise that AutoIt would only be interacting with the third-party program, but that is close enough. M23
    2 points
  3. Yashied

    Restart UDF

    LAST VERSION - 1.0 07-Mar-10 This is my very simple and small UDF. Allows you to restart the script from any location with full restoration of the original command line parameters. I use this library in several of my programs, and I was not disappointed. I hope this UDF will be useful for many as for me. I will be glad to any feedback and suggestions. Restart UDF Library v1.0 Previous downloads: 943 Restart.au3 Example #NoTrayIcon #Include <Misc.au3> #Include <Restart.au3> _Singleton('MyProgram') If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then _ScriptRestart() EndIf
    1 point
  4. If you ever tried to download some remote file from your script using InetGet(), InetRead() or other download functions, you probably noticed that the download speed was never as good as when you try to download the same file using a download manager. But that's over, you won't lack the high speed download capability of download managers in your AutoIt scripts, not anymore. Enjoy: #include-once #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <WinHttp.au3> ;http://www.autoitscript.com/forum/topic/84133-winhttp-functions/ #include <FileConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: UrlDownloadEx ; Description ...: Download a single file by splitting it in segments and using several simultaneous connections to download these segments from a single server. ; Syntax ........: UrlDownloadEx($sUrl [, $sFileName = Default [, $iNumberOfConnections = Default [, $CallbackFunction = Default [, $vParam = 0]]]]) ; Parameters ....: $sUrl - Url of the file to download. ; $sFileName - [optional] Local filename to download to. Default is "". ; $iNumberOfConnections - [optional] Number of simultaneous connections. Default is 8. ; $CallbackFunction - [optional] An application-defined callback function to call when progress is made. Default is Null. ; $vParam - [optional] An application-defined value to be passed to the callback function. Default is 0. ; Return values .: Success - Returns a binary string if file name is not supplied. ; - Returns 1 if file name is supplied ; - @extended receives the number of received bytes. ; Failure - Returns 0 and sets @error: ; |1 - Invalid number of connections ; |2 - Invalid callback function ; |3 - Invalid url ; |4 - _WinHttpOpen failed ; |5 - _WinHttpConnect failed ; |6 - _WinHttpOpenRequest failed ; |7 - _WinHttpSendRequest failed ; |8 - _WinHttpReceiveResponse failed ; |9 - _WinHttpQueryHeaders failed ; |10 - _WinHttpOpenRequest failed, while trying to create multiple request ; |11 - _WinHttpQueryHeaders failed, while trying to prepare multiple request ; |12 - Not enough memory to allocate buffer ; |13 - _WinHttpQueryDataAvailable failed ; |14 - Download aborted, callback function returned False ; |15 - FileOpen failed ; |16 - FileWrite failed ; Author ........: FaridAgl ; Remarks .......: The Url parameter should be in the form "http://www.somesite.com/path/file.html", just like an address you would type into your web browser. ; + Please use a high number of connections with caution. Some servers may have specific limitations for a number of connections from one client, when the number of connections is high, the servers can put your computer to a black list. ; + For some connection types or for low performance computers or routers, the download speed may decrease when you increase the number of connections. ; + The callback function is called with the following parameters: $iReceivedBytes, $iTotalReceivedBytes, $iDownloadSize, $vParam ; + To continue downloading, the callback function must return True; to stop downloading, it must return False. ; Example .......: Yes ; =============================================================================================================================== Func UrlDownloadEx($sUrl, $sFileName = Default, $iNumberOfConnections = Default, $CallbackFunction = Default, $vParam = 0) If ($sFileName = Default Or $sFileName = -1) Then $sFileName = "" If ($iNumberOfConnections = Default Or $iNumberOfConnections = -1) Then $iNumberOfConnections = 8 ElseIf (IsInt($iNumberOfConnections) = 0 Or $iNumberOfConnections < 1) Then Return SetError(1, 0, 0) EndIf If ($CallbackFunction = Default Or $CallbackFunction = -1) Then $CallbackFunction = Null Else If (IsFunc($CallbackFunction) = 0) Then Return SetError(2, 0, 0) EndIf Local $avUrlComponents = _WinHttpCrackUrl($sUrl, $ICU_DECODE) If ($avUrlComponents = 0) Then Return SetError(3, 0, 0) Local Const $SERVER_NAME = $avUrlComponents[2] Local Const $OBJECT_NAME = $avUrlComponents[6] Local Const $SERVER_PORT = $avUrlComponents[3] Local Const $FLAGS = ($avUrlComponents[1] = $INTERNET_SCHEME_HTTPS) ? ($WINHTTP_FLAG_SECURE) : (0) Local $hSession = _WinHttpOpen("Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))", $WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, $WINHTTP_NO_PROXY_NAME, $WINHTTP_NO_PROXY_BYPASS, 0) If ($hSession = 0) Then Return SetError(4, 0, 0) Local $hConnect = _WinHttpConnect($hSession, $SERVER_NAME, $SERVER_PORT) If ($hConnect = 0) Then _WinHttpCloseHandle($hSession) Return SetError(5, 0, 0) EndIf Local $hRequest = _WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, 0, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS) If ($hRequest = 0) Then _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(6, 0, 0) EndIf If (_WinHttpSendRequest($hRequest, "Range: bytes=0-0", $WINHTTP_NO_REQUEST_DATA, 0, 0) = 0) Then _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(7, 0, 0) EndIf If (_WinHttpReceiveResponse($hRequest) = 0) Then _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(8, 0, 0) EndIf Local $sStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE, $WINHTTP_HEADER_NAME_BY_INDEX, $WINHTTP_NO_HEADER_INDEX) If (Int($sStatusCode, 1) <> $HTTP_STATUS_PARTIAL_CONTENT) Then _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(9, 0, 0) EndIf Local $sContentRange = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_RANGE, $WINHTTP_HEADER_NAME_BY_INDEX, $WINHTTP_NO_HEADER_INDEX) _WinHttpCloseHandle($hRequest) Local Enum $REQUEST_HANDLE, $RECEIVED_BYTES, $DOWNLOAD_OFFSET, $BYTES_TO_DOWNLOAD Local $avConnections[$iNumberOfConnections][4] Local $iDownloadSize = Int(StringTrimLeft($sContentRange, StringLen("bytes 0-0/")), 1) Local $iDownloadSizePerConnection = Floor($iDownloadSize / $iNumberOfConnections) Local $iLastByteToDownload = 0 For $i = 0 To $iNumberOfConnections - 1 $avConnections[$i][$REQUEST_HANDLE] = _WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, 0, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS) If ($avConnections[$i][$REQUEST_HANDLE] = 0) Then For $j = $i - 1 To 0 Step -1 _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(10, 0, 0) EndIf $avConnections[$i][$RECEIVED_BYTES] = 0 $avConnections[$i][$DOWNLOAD_OFFSET] = $i * $iDownloadSizePerConnection If ($i <> $iNumberOfConnections - 1) Then $avConnections[$i][$BYTES_TO_DOWNLOAD] = $iDownloadSizePerConnection $iLastByteToDownload = $avConnections[$i][$DOWNLOAD_OFFSET] + $iDownloadSizePerConnection - 1 Else $avConnections[$i][$BYTES_TO_DOWNLOAD] = $iDownloadSizePerConnection + Mod($iDownloadSize, $iNumberOfConnections) $iLastByteToDownload = $iDownloadSize - 1 EndIf _WinHttpSendRequest($avConnections[$i][$REQUEST_HANDLE], "Range: bytes=" & $avConnections[$i][$DOWNLOAD_OFFSET] & "-" & $iLastByteToDownload, $WINHTTP_NO_REQUEST_DATA, 0, 0) _WinHttpReceiveResponse($avConnections[$i][$REQUEST_HANDLE]) $sStatusCode = _WinHttpQueryHeaders($avConnections[$i][$REQUEST_HANDLE], $WINHTTP_QUERY_STATUS_CODE, $WINHTTP_HEADER_NAME_BY_INDEX, $WINHTTP_NO_HEADER_INDEX) If (Int($sStatusCode, 1) <> $HTTP_STATUS_PARTIAL_CONTENT) Then For $j = $i - 1 To 0 Step -1 _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(11, 0, 0) EndIf Next Local $tBuffer = DllStructCreate("BYTE[" & $iDownloadSize & "]") If (@error) Then Return SetError(12, 0, 0) Local $pBuffer = DllStructGetPtr($tBuffer) Local $iTotalReceivedBytes = 0 While (True) For $i = 0 To $iNumberOfConnections - 1 If ($avConnections[$i][$RECEIVED_BYTES] = $avConnections[$i][$BYTES_TO_DOWNLOAD]) Then ContinueLoop If (_WinHttpQueryDataAvailable($avConnections[$i][$REQUEST_HANDLE]) = 1) Then $iTotalReceivedBytes += @extended _WinHttpReadData($avConnections[$i][$REQUEST_HANDLE], 2, @extended, $pBuffer + $avConnections[$i][$DOWNLOAD_OFFSET] + $avConnections[$i][$RECEIVED_BYTES]) $avConnections[$i][$RECEIVED_BYTES] += @extended If ($CallbackFunction <> Null) Then If ($CallbackFunction(@extended, $iTotalReceivedBytes, $iDownloadSize, $vParam) = False) Then For $j = 0 To $iNumberOfConnections - 1 If ($avConnections[$j][$REQUEST_HANDLE] > 0) Then _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(14, 0, 0) EndIf EndIf If ($avConnections[$i][$RECEIVED_BYTES] = $avConnections[$i][$BYTES_TO_DOWNLOAD]) Then _WinHttpCloseHandle($avConnections[$i][$REQUEST_HANDLE]) $avConnections[$i][$REQUEST_HANDLE] = 0 EndIf Else For $j = 0 To $iNumberOfConnections - 1 If ($avConnections[$j][$REQUEST_HANDLE] > 0) Then _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(13, 0, 0) EndIf Next If ($iTotalReceivedBytes = $iDownloadSize) Then _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) ExitLoop EndIf WEnd If ($sFileName <> "") Then Local $hFile = FileOpen($sFileName, BitOR($FO_OVERWRITE, $FO_CREATEPATH, $FO_BINARY)) If ($hFile = -1) Then Return SetError(15, 0, 0) If (FileWrite($hFile, DllStructGetData($tBuffer, 1)) = 0) Then FileClose($hFile) Return SetError(16, 0, 0) EndIf FileClose($hFile) Return SetError(0, $iDownloadSize, 1) EndIf Return SetError(0, $iDownloadSize, DllStructGetData($tBuffer, 1)) EndFunc Example 1 - Download to a local file and use callback function to monitor and control the download progress: #include "UrlDownloadEx.au3" Global $t1 = TimerInit() Global $vResult = UrlDownloadEx("http://www.autoitscript.com/files/autoit3/autoit-v3-setup.exe", @ScriptDir & "\AutoIt 3.3.12.0.exe", Default, BytesReceived) ConsoleWrite(StringFormat("Result:\t%s\nSize:\t%u\nError:\t%u\nTimer:\t%u\n", $vResult, @extended, @error, TimerDiff($t1))) Func BytesReceived($iReceivedBytes, $iTotalReceivedBytes, $iDownloadSize, $vParam) If ($iTotalReceivedBytes >= 2 * 1024 * 1024) Then Return False ;Stop downloading ConsoleWrite(StringFormat("%u bytes received.\n%u/%u\nParam: %s\n\n", $iReceivedBytes, $iTotalReceivedBytes, $iDownloadSize, $vParam)) Return True ;Continue downloading EndFunc Example 2 - Download to memory and set the number of connections to 2: #include "UrlDownloadEx.au3" Global $t1 = TimerInit() Global $vResult = UrlDownloadEx("http://icdn4.digitaltrends.com/image/microsoft_xp_bliss_desktop_image-650x0.jpg", Default, 2) ConsoleWrite(StringFormat("Result:\t%s\nSize:\t%u\nError:\t%u\nTimer:\t%u\n", $vResult, @extended, @error, TimerDiff($t1))) You can also download all of the above scripts at once: UrlDownloadEx + Examples.zip
    1 point
  5. pixelsearch, YES YES YES !!! I found out why I get problems with this downloads. By default in Windows 7 (don't know, maybe in more late versions too) max connection per ONE server is only 2. As I can assume InetGet somehow related to Windows system settings and that's why it's allow only 2 simultaneous downloads with followed problematic 0 bytes downloads. So I started search how to increase this value and found out, that this Windows Register Keys do the trick: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings] "MaxConnectionsPer1_0Server"=dword:00000010 "MaxConnectionsPerServer"=dword:00000010 This parameters increase max connections per ONE server to 10, so now I just could handle in my scripts this number of connections and do not come across with this 0-bytes downloads troubles! This info needs to be added to InetGet() help reference! I'm so happy to figure out this thing! P.S. Here the .gif where I'M THE LORD OF MY DOWNLOADS!
    1 point
  6. @Tersion : thanks for your kind words. So it seems you found a bug a few hours ago, in the other topic you mentioned (confirmed by mikell, aka "Soulful cat", best avatar on the Forum !) You did great creating a ticket in Bug Tracker, concerning InetClose() . But now if InetClose() isn't reliable, there's no use in trying to understand why it takes 10 seconds using a bugged function, I guess we'll have to wait for a fix concerning this issue in a future AutoIt release. You ask what to do to terminate your downloads if 0 bytes are returned, because you don't want to wait 10s to close them with the buggy function. If no empty file has been written on your hard drive. Why not doing nothing concerning this empty download (don't close anything if 0 bytes were returned) then restart it when you know there is only 1 ongoing download (the 2nd one has terminated) as your download server doesn't allow more than 2 simultaneous download. Well you sure will have many tries to do (it seems you already made a lot !) And concerning this other InetGet() function, which returns a handle OR a number of bytes downloaded when it succeeds, depending on a parameter found or not in the function call... best way to start troubles ! Good luck for your future downloads
    1 point
  7. here one of possible ways... https://www.autoitscript.com/forum/topic/155726-searching-for-a-string-after-the-string/?do=findComment&comment=1174545
    1 point
  8. water

    Creating an Exchange Mailbox

    Great. I have added the functiont to the AD UDF so it will be available with the next release
    1 point
  9. In your first expression, just change this ?: to this ?| and please refer to the helpfile for explanations
    1 point
  10. Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Moderation Team
    1 point
  11. Take a look at this code: Easy shell hook Should be trivial to make a app logger with it.
    1 point
  12. It failed because according to the help file for COM Events, AutoIt can only receive 'dispatch' type events. The WinHttp.WinHttpRequest.5.1 events are not 'dispatch' type events. They don't have an IDispatch interface they have an interface of IUknown.
    1 point
  13. trancexx

    API Upload XML WinHttp

    Ok, done. The example would be: #include "WinHTTP.au3" $sAddress = "https://posttestserver.com/post.php?dir=WinHttp" ; the address of the target (https or http, makes no difference - handled automatically) ; Select some file $sFileToUpload = FileOpenDialog("Select file to upload...", "", "All Files (*)") If Not $sFileToUpload Then Exit 5 ; check if the file is selected and exit if not $sForm = _ '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="upload"/>' & _ '</form>' ; Initialize and get session handle $hOpen = _WinHttpOpen() $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref ; Creates progress bar window ProgressOn("UPLOADING", $sFileToUpload, "0%") ; Register callback function _WinHttpSimpleFormFill_SetCallback(UploadCallback) ; Fill form $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ "name:upload", $sFileToUpload) ; Collect error number $iErr = @error ; Unregister callback function _WinHttpSimpleFormFill_SetCallback(0) ; Kill progress bar window ProgressOff() ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If $iErr Then MsgBox(4096, "Error", "Error number = " & $iErr) Else ConsoleWrite($sHTML & @CRLF) MsgBox(4096, "Success", $sHTML) EndIf ; Callback function. For example, update progress control Func UploadCallback($iPrecent) If $iPrecent = 100 Then ProgressSet(100, "Done", "Complete") Sleep(800) ; give some time for the progress bar to fill-in completely Else ProgressSet($iPrecent, $iPrecent & "%") EndIf EndFuncAnd the latest (working version of) WinHttp.au3 is at https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3 Try it, maybe I leave it in.
    1 point
  14. trancexx

    WinHTTP functions

    But you never get progress updates from the server. You've lost me now. If you want detailed report of the whole process there is option to use callback function. Like this maybe: #include "WinHttp.au3" Const $sClientID = "555555555555555" ; your client-id Const $sAddress = "https://api.imgur.com/3/upload.xml" ; the address of the target (https or http, makes no difference - handled automatically) Const $sForm = _ '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="image"/>' & _ ; '</form>' $sFileToUpload = FileOpenDialog("Open", "", "Images (*.jpg;*.gif;*.png;*.bmp)") ; Initialize and get session handle $hOpen = _WinHttpOpen() Const $hWINHTTP_STATUS_CALLBACK = DllCallbackRegister(__WINHTTP_STATUS_CALLBACK, "none", "handle;dword_ptr;dword;ptr;dword") ; Associate callback function with session _WinHttpSetStatusCallback($hOpen, $hWINHTTP_STATUS_CALLBACK) $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref ; Fill form $sReturned = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ "name:image", $sFileToUpload, _ "Authorization: Client-ID " & $sClientID) If @error Then MsgBox(4096, "Error", "Error number = " & @error) Else ConsoleWrite(@CRLF & $sReturned & @CRLF) EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) DllCallbackFree($hWINHTTP_STATUS_CALLBACK) ; Define callback function Func __WINHTTP_STATUS_CALLBACK($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength) #forceref $hInternet, $iContext, $pStatusInformation, $iStatusInformationLength ConsoleWrite("--> ") ; Interpret the status Local $sStatus Switch $iInternetStatus Case $WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION $sStatus = "Closing the connection to the server" Case $WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER $sStatus = "Successfully connected to the server." Case $WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER $sStatus = "Connecting to the server." Case $WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED $sStatus = "Successfully closed the connection to the server." Case $WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE $sStatus = "Data is available to be retrieved with WinHttpReadData." Case $WINHTTP_CALLBACK_STATUS_HANDLE_CREATED $sStatus = "An HINTERNET handle has been created." Case $WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING $sStatus = "Handle has been terminated." Case $WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE $sStatus = "The response header has been received and is available with WinHttpQueryHeaders." Case $WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE $sStatus = "Received an intermediate (100 level) status code message from the server." Case $WINHTTP_CALLBACK_STATUS_NAME_RESOLVED $sStatus = "Successfully found the IP address of the server." Case $WINHTTP_CALLBACK_STATUS_READ_COMPLETE $sStatus = "Data was successfully read from the server." Case $WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE $sStatus = "Waiting for the server to respond to a request." Case $WINHTTP_CALLBACK_STATUS_REDIRECT $sStatus = "An HTTP request is about to automatically redirect the request." Case $WINHTTP_CALLBACK_STATUS_REQUEST_ERROR $sStatus = "An error occurred while sending an HTTP request." Case $WINHTTP_CALLBACK_STATUS_REQUEST_SENT $sStatus = "Successfully sent the information request to the server." Case $WINHTTP_CALLBACK_STATUS_RESOLVING_NAME $sStatus = "Looking up the IP address of a server name." Case $WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED $sStatus = "Successfully received a response from the server." Case $WINHTTP_CALLBACK_STATUS_SECURE_FAILURE $sStatus = "One or more errors were encountered while retrieving a Secure Sockets Layer (SSL) certificate from the server." Case $WINHTTP_CALLBACK_STATUS_SENDING_REQUEST $sStatus = "Sending the information request to the server." Case $WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE $sStatus = "The request completed successfully." Case $WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE $sStatus = "Data was successfully written to the server." EndSwitch ; Print it ConsoleWrite($sStatus & @CRLF) EndFunc
    1 point
  15. Found this in the help file: ; Post a WM_COMMAND message to a ctrl in a gui window Func PostButClick($hWnd, $nCtrlID) DllCall("user32.dll", "int", "PostMessage", _ "hwnd", $hWnd, _ "int", 0x0111, _ ; $WM_COMMAND "int", BitAND($nCtrlID, 0x0000FFFF), _ "hwnd", GUICtrlGetHandle($nCtrlID)) EndFunc ;==>PostButClick
    1 point
  16. A lot of my scripts are to add functions to other programs. The following is my template in these cases. I use the script instead of calling the program directly and have the script call it. I then add whatever hotkeys and other stuff to watch for in the script. This also exits the script after the program closes. BTW. I've always put a sleep in there with the while statement. I don't know if that's needed or not. I've always assumed that a sleep line would use less processing power then always checking a while statement that can never change. also always make sure you have some way of exiting the script. Either my method here or hotkey. Unless of course the intention is to always run as long as the computer is on. I have a couple that do that too. ; ----- run some program If Not WinExists(' program win title ') Then Run('program path exe', '') WinWaitActive('prog name') Sleep(2000) Else WinSetState('program ', '', @SW_SHOW) ; if in tray, this will make it show. WinActivate('program ', '') ; I've got some apss that need this too to come into focus. EndIf are_we_done('exe of program that shows in tskmgr', 5) ; exe of prog, timeout in sec ; setup whatever else you need to interact with the program. ; at end of script. While 1 Sleep(30000) WEnd ; watch for program close. Func are_we_done($process_name2,$timout_value) Global $process_name = '' $process_name = $process_name2 AdlibEnable("are_we_done_2", $timout_value * 1000) EndFunc ;==>are_we_done Func are_we_done_2() $pid = ProcessExists($process_name) If $pid == 0 Then Exit EndFunc
    1 point
  17. This COM object is hosted by the same DLL an is build upon the same functions. Regardless of that you won't be able to use IWinHttpRequestEvents, primarily because that sort of interfaces are not supported by automation (inherits from IUnknown). New beta AutoIt have ability to detect this kind of situations and report them to the user. Meaning if you use AutoIt beta, there won't be unexpected behaviors. Another thing to consider is reentrant WinHTTP nature during the asynchronous completion callback. This means that even if IWinHttpRequestEvents could be used (future AutoIt versions) you would still have problems with the semantics of your code.
    0 points
×
×
  • Create New...