Sign in to follow this  
Followers 0
er453r

Networking lags the script

3 posts in this topic

Hi. So I'm using INet functions in my script, but during INet requests the GUI becomes useless. There's no multi-threading in AutoIt, so one possible solution is to start 2 programs (one for GUI, one for the script) sharing information with each other.

Maybe someone knows a better solution?

Big thanks in advance :)

Share this post


Link to post
Share on other sites



Hi. So I'm using INet functions in my script, but during INet requests the GUI becomes useless. There's no multi-threading in AutoIt, so one possible solution is to start 2 programs (one for GUI, one for the script) sharing information with each other.

Maybe someone knows a better solution?

Big thanks in advance :)

You just need to use the "background" option of INetGet():

#include <guiconstants.au3>

Opt("GuiOnEventMode", 1)

Global $InetBytes = 0

$hGUI = GUICreate("Test", 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUICtrlCreateButton("QUIT", 100, 160, 100, 30)
GUICtrlSetOnEvent(-1, "_Quit")
$Label = GUICtrlCreateLabel("", 10, 10, 280, 20, $SS_CENTER)
GUISetState()

InetGet("http://www.google.com", "C:\Temp\google.html", 1, 1)
$Timer = TimerInit()

While 1
    Sleep(20)
    If @InetGetActive Then
        If @InetGetBytesRead <> $InetBytes Then
            $InetBytes = @InetGetBytesRead
            GUICtrlSetData($Label, "Downloaded: " & $InetBytes & " bytes")
        EndIf
    Else
        If $Timer Then
            $InetBytes = @InetGetBytesRead
            GUICtrlSetData($Label, "Finished: " & $InetBytes & " bytes in " & Round(TimerDiff($Timer) / 1000, 3) & " secs")
            $Timer = 0
        EndIf
    EndIf
WEnd

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Wow. It seems that I just have to read the manual more carefully :)

Thank you very much :)

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
Sign in to follow this  
Followers 0