Jump to content

InetGetInfo not working for me?


Go to solution Solved by Andreik,

Recommended Posts

I am attempting to fetch a download and wait until the download is complete but I never get past it downloading and I am not seeing much relating to this as it doesn't seem to ever be an issue.

Func versionCheck()
    $getVersion = InetGet("URL/File", @TempDir & "\File", 1)
    Do
        ConsoleWrite($getVersion) & @CRLF) ;trying to troubleshoot
        Sleep(2000)
    Until InetGetInfo($getVersion, 2) ;This is never satisfied and just locks up the program
    InetClose($getVersion)
    MsgBox(0, "", "Complete")
EndFunc

I can see the file is successfully downloaded to the temp directory and I can open it. What's the deal?

Link to comment
Share on other sites

23 minutes ago, Danp2 said:

This could be due to an issue with security on the site being accessed. Can you post a version that we can actually run to reproduce the issue?

Also, what version of AutoIt and Windows are you running?

Try this, just tested and can see the file get downloaded into temp directory. I kept the file structure similar for testing (.version) but it's just the au3 file itself.

#include <MsgBoxConstants.au3>
#include <InetConstants.au3>

versionCheck()
Func versionCheck()
    ShellExecute(@TempDir)
    $getVersion = InetGet("https://filebin.net/dtl7wvzrdd63wmfl/versiontest.au3", @TempDir & "\File.version")
    Do
    Until InetGetInfo($getVersion, 2) ;This is never satisfied and just locks up the program
    InetClose($getVersion)
    MsgBox(0, "", "Complete")
EndFunc

I am running Windows 10 and using AutoIt 3.3.14.5

 

EDIT:
I just updated to 3.3.16.1

Edited by kjpolker
Link to comment
Share on other sites

  • Solution
#include <MsgBoxConstants.au3>
#include <InetConstants.au3>

versionCheck()

Func versionCheck()
    ShellExecute(@TempDir)
    $getVersion = InetGet("https://filebin.net/dtl7wvzrdd63wmfl/versiontest.au3", @TempDir & "\File.version", 1, 1)
    Do
        Sleep(10)
    Until InetGetInfo($getVersion, 2) ;This is never satisfied and just locks up the program
    InetClose($getVersion)
    MsgBox(0, "", FileRead(@TempDir & "\File.version"))
EndFunc

or

#include <MsgBoxConstants.au3>
#include <InetConstants.au3>

versionCheck()

Func versionCheck()
    ShellExecute(@TempDir)
    InetGet("https://filebin.net/dtl7wvzrdd63wmfl/versiontest.au3", @TempDir & "\File.version", 1, 0)
    MsgBox(0, "", FileRead(@TempDir & "\File.version"))
EndFunc

 

Edited by Andreik
Link to comment
Share on other sites

There is no issue, InetGet() works in 2 different ways. If you specify INET_DOWNLOADBACKGROUND then function return a handle that can be used with InetGetInfo() to get more info about the download process. If you use INET_DOWNLOADWAIT (default mode) the function wait until the download is done and return the number of bytes downloaded. In your case default mode was implicit but you expected to use InetGetInfo() and this doesn't work. I used INET_FORCERELOAD just to be sure I don't get anything from cache.

Edited by Andreik
Link to comment
Share on other sites

@Andreik Ahhh, I feel like a dummy. Thank you for clarifying! Can I still use @error to capture an incomplete or Windows defender issue of removing the file? Is there a built in timeout for a return of 0?

Edited by kjpolker
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...