j0kky

InetGet bug?

3 posts in this topic

#1 ·  Posted (edited)

Hi guys,

I have the last version of Autoit and Windows 7, if I execute this testing script:

#include <InetConstants.au3>

ConsoleWrite("WAIT TEST" & @CRLF & @CRLF)
$name = @TempDir & "\filetransfer" & Random(100, 999, 1)
$hInet = InetGet("http://www.google.com", $name, $INET_FORCERELOAD, $INET_DOWNLOADWAIT)
$nSize = FileGetSize($name)
ConsoleWrite("SUCCESS" & @CRLF & _
        @TAB & "Number of bytes: " & $hInet & @CRLF & _
        @TAB & "Size of the file: " & $nSize & @CRLF)
FileDelete($name)

$name = @TempDir & "\filetransfer" & Random(100, 999, 1)
$hInet = InetGet("http://www.google.xxx", $name, $INET_FORCERELOAD, $INET_DOWNLOADWAIT) ;wrong URL
$nSize = FileGetSize($name)
ConsoleWrite("FAILURE" & @CRLF & _
        @TAB & "Number of bytes: " & $hInet & @CRLF & _
        @TAB & "Size of the file: " & $nSize & @CRLF)
FileDelete($name)

ConsoleWrite(@CRLF & "BACKGROUND TEST" & @CRLF & @CRLF)
$name = @TempDir & "\filetransfer" & Random(100, 999, 1)
$hInet = InetGet("http://www.google.com", $name, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
$sAnwser = IsHWnd($hInet) ? "Yes" : "No"
Sleep(5000)
$nSize = FileGetSize($name)
ConsoleWrite('SUCCESS with sleep' & @CRLF & _
        @TAB & "Handle: " & $hInet & @CRLF & _
        @TAB & "Is really an handle? " & $sAnwser & @CRLF & _
        @TAB & "Size of the file: " & $nSize & @CRLF)
FileDelete($name)

$name = @TempDir & "\filetransfer" & Random(100, 999, 1)
$hInet = InetGet("http://www.google.com", $name, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
$sAnwser = IsHWnd($hInet) ? "Yes" : "No"
$nSize = FileGetSize($name)
ConsoleWrite('SUCCESS with no sleep' & @CRLF & _
        @TAB & "Handle: " & $hInet & @CRLF & _
        @TAB & "Is really an handle? " & $sAnwser & @CRLF & _
        @TAB & "Size of the file: " & $nSize & @CRLF)
FileDelete($name)

$name = @TempDir & "\filetransfer" & Random(100, 999, 1)
$hInet = InetGet("http://www.google.xxx", $name, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ;wrong url
$sAnwser = IsHWnd($hInet) ? "Yes" : "No"
$nSize = FileGetSize($name)
ConsoleWrite('FAILURE' & @CRLF & _
        @TAB & "Handle: " & $hInet & @CRLF & _
        @TAB & "Is really an handle? " & $sAnwser & @CRLF & _
        @TAB & "Size of the file: " & $nSize & @CRLF)
FileDelete($name)

I obtain this output:

WAIT TEST

SUCCESS
    Number of bytes: 19163
    Size of the file: 19163
FAILURE
    Number of bytes: 0
    Size of the file: 0

BACKGROUND TEST

SUCCESS with sleep
    Handle: 3
    Is really an handle? No
    Size of the file: 19163
SUCCESS with no sleep
    Handle: 4
    Is really an handle? No
    Size of the file: 0
FAILURE
    Handle: 5
    Is really an handle? No
    Size of the file: 0

According to Help File, using InetGet with $INET_DOWNLOADBACKGROUND flag, I should get an handle for InetGetInfo function... but instead of it I get a number which seems the current number of downloads (the same that I get if I call InetGetInfo with no arguments).

Does it happens with your operative system and Autoit version too?

Edited by j0kky

Share this post


Link to post
Share on other sites



The "handle" you get is the internal AutoIt id number, not a windows handle from what I can tell.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • leb
      By leb
      Hello there,
      I am using the function InetGet example in the help files on a website and getting the error 13. First, I searched the help files and the forum for a list of errors to consult to no avail. I suspect this is a 400's server reply based error but it would be nice to get more info about it.
      Please help, thanks.
      L
    • Dante_t
      By Dante_t
      Hi Guys, I need help. I have searched the forum before posting and i couldn't find anything. The code below works fine when downloading files from "http" sites, but when trying to download from "https" sites, no files are downloaded. I tried different sites and I experience the same problem everywhere. Is there something I'm missing or doing wrong? Please note that I'm not a programmer and I'm new to this. I'm just using logic wherever i can to get things done. your help will be highly appreciated.
       
      #include <InetConstants.au3>
      #include <MsgBoxConstants.au3>
      #include <WinAPIFiles.au3>
      ; Download a file in the background.
      ; Wait for the download to complete.

      Example()
      Func Example()
          ; Save the downloaded file to the temporary folder.
          Local $sFilePath = "d:\"
          ; Download the file in the background with the selected option of 'force a reload from the remote site.'
          Local $hDownload = InetGet("https://en.wikipedia.org/wiki/HTTPS#/media/File:Internet2.jpg", $sFilePath& "Internet2.jpg", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
          ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
          Do
              Sleep(250)
          Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
          ; Retrieve the number of total bytes received and the filesize.
          Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
          Local $iFileSize = FileGetSize($sFilePath&"Internet2.jpg")
          ; Close the handle returned by InetGet.
          InetClose($hDownload)
          ; Display details about the total number of bytes read and the filesize.
          MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
                  "The total filesize: " & $iFileSize)
          ; Delete the file.
          ;FileDelete($sFilePath)
      EndFunc   ;==>Example
       
    • swatsapkraz
      By swatsapkraz
      First script here. Thanks for taking the time.
      I want to download a file from my dropbox or other cloud file host and I want autoit to read the file and proceed.
      Here are the references I've gone through, it's just I'm not familiar yet with autoit so I'm looking for advice:
      https://www.autoitscript.com/autoit3/docs/functions/InetGet.htm
      https://www.autoitscript.com/autoit3/docs/functions/FileRead.htm
       
      How would I start out downloading a text file from dropbox and if in the file there is a 1 then it will proceed with the rest of the script if there is a 0 or if the file cannot be downloaded I want it to just end.
       
      Thank you for taking the time to read this and I apologize in advance if this seems very trivial for some but this is my first script and I'm hoping this is the correct place to ask this question.
    • jonson1986
      By jonson1986
      Hey
      I'm trying to use InetGet function to download multiple images from a website, some pages having three images, some pages having 4 images some of them having more...
      I wrote belong codes to work with autoit and having issues when autoit find not matching url available then autoit just script stopped without any error and I just want to same all the avaialble images on the website if links are not more left then script should moves on but script just stopped...
      Here is complete scenerio
      I've so many webpages with random number of images are hosting on those pages, in below code, InetGet able to download first three files easily and when it reaches to 4th link that is missing on the webpage that's why script stopped just but I want autoit to download only those images those are links are available and rest of files needs to be skipped automatically for this page if on the next page 4th link of image avaiable then autoit script needs to download 4th one also.
      Furthermore, please help me to download files with it's original names instead of whatever name I want to same them like in InetGet I've to give some name to the file that I'm willind to download instead of original name that is available online.
      Please Help me.
      Here i my code;
      $File6 = @ScriptDir & "\images_source.txt" $txt6 = FileRead($File6) $target_source7 = _StringBetween($txt6, 'src="', '"') if Not @error Then InetGet ( $target_source7[0], @ScriptDir & '\Description\Image1.jpg'); 1st image download coz link is available InetGet ( $target_source7[1], @ScriptDir & '\Description\Image2.jpg'); 2nd image download coz link is available InetGet ( $target_source7[2], @ScriptDir & '\Description\Image3.jpg'); 3rd image download coz link is available InetGet ( $target_source7[3], @ScriptDir & '\Description\Image4.jpg'); 4th image not able to download coz link is not available and script just stopped EndIf  
    • 31290
      By 31290
      Hi Guys, 
      Since I'm able to get a Dell equipment warranty status thanks to my API key, I'm using an UDF to extract data from an XML file and get the end date. > 
      Thing is, when using InetGet, the original file is in JSON format and the UDF is not working anymore, even if I download the file with the xml extension. Therefore, and when I manually download the page with Chrome, I have a proper XML file where the UDF is working fine.
      Here's my code:
      I even tried to convert the json to xml > https://www.autoitscript.com/forum/topic/185717-js-json-to-xml/
      I took a look here https://www.autoitscript.com/forum/topic/104150-json-udf-library-fully-rfc4627-compliant/ but I don't understand anything :/
       
      The XML read UDF is just perfect for my needs but I'm stuck here... 
      Thanks for any help you can provide
      -31290-
      3MTXM12.json
      3MTXM12.xml