Jump to content

checking connection through the operation !


Recommended Posts

hello everybody 

I made a script to check internet connection through any IE operation

Func _CHCK_IP()

    Local $sPublicIP = _GetIP()
    Local $1st_chck_sign = ""
    ;================================================
    If $sPublicIP = -1 or $sPublicIP = "" Then ; this condition to make a sign to not refresh page when get IP until the connection has been already cut
        $1st_chck_sign = True
    EndIf
    ;================================================
    While 1
        If $sPublicIP <> -1 and $sPublicIP <> "" Then
            ;--------------------------------
            if $1st_chck_sign = True then
                _IEAction($oIE, "refresh")
                $1st_chck_sign = ""
                _GUICtrlStatusBar_SetText($Gnrl_Statusbar, "Online again 😄", 0)
            EndIf
            ;--------------------------------
            _IELoadWait($oIE)
            ExitLoop
        Else
            _GUICtrlStatusBar_SetText($Gnrl_Statusbar, "There is a connetion problem. As soon as it's back, the script will go on", 0)
            Sleep(500)
        EndIf

        $sPublicIP = _GetIP()
        ConsoleWrite("$sPublicIP: "&$sPublicIP&@CRLF)
        Sleep(50)

    WEnd
    ;================================================
EndFunc

I put this function after _IELoadWait($oIE) in each place in _IE operation 

example: 

Local $oIE = _IECreate($url)
_IELoadWait($oIE,100)
_CHCK_IP()
Local $objs_html = _IEDocReadHTML($oIE)

but I feel the code becomes slow :(

is there anyway the code could check the connection after each step ?? 

Edited by AlienStar
Link to comment
Share on other sites

33 minutes ago, Chimp said:

couldn't you just use the ping() function?

I made this function to prevent moving to the next step before ensure that it's online 

so if I use ping() or _GetIP()  I must make a loop to ensure working online 

 

Link to comment
Share on other sites

if you need this for the problem of your other post, then I don't think that the non-referencing to an object on the web page could be due to the absence of the link, maybe it could be caused by a delay on creating that object on the page web, and maybe the script tries to reference it before this is created on the web page. Better checking could be done by making sure the object has been referenced before continuing with the rest of the script. for example more or less with something like this:

Do
    $title = _IEGetObjById($oIE, "title")
Until IsObj($title)

 

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

4 hours ago, Chimp said:

if you need this for the problem of your other post, then I don't think that the non-referencing to an object on the web page could be due to the absence of the link, maybe it could be caused by a delay on creating that object on the page web, and maybe the script tries to reference it before this is created on the web page. Better checking could be done by making sure the object has been referenced before continuing with the rest of the script. for example more or less with something like this:

Do
    $title = _IEGetObjById($oIE, "title")
Until IsObj($title)

 

I agree with your idea and I'll try this loop cause I think it might works 

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...