Jump to content

Recommended Posts

Posted (edited)

Hi need help on this, I wrote a script to monitor if my wireless connection get disconnected to the modem/ROUTER,
 I want the message box to disappear if my wireless connection is already connected, BUT dont know how to do it,if i put Exit and Exitloop it is exiting my whole script. so i removed exit and exitloop command. if i dont put exit and exitloop messagebox keeps poping up..

 

While 1
    If _IsInternetConnected() = 0 Then
        MsgBox(0, "Alert!!!", "F566 Disconnected!!!")
    ElseIf _IsInternetConnected() = 1 Then
        MsgBox(0, "Alert!!!", "F566 Connected!!!")
    EndIf
WEnd

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then
        Return SetError(1, 0, False)
    EndIf
    Return $aReturn[0] = 0
EndFunc   ;==>_IsInternetConnected

 

 

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Posted (edited)

 

While 1
    If _IsInternetConnected() = 0 Then
        MsgBox(0, "Alert!!!", "F566 Disconnected!!!")
    EndIf
WEnd

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then
        Return SetError(1, 0, False)
    EndIf
    Return $aReturn[0] = 0
EndFunc   ;==>_IsInternetConnected

 

 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted (edited)

I think it can be a good example:

_main()

Func _main()
    While 1
        ; here main loop
        ;
        ;
        _my_func()
        ;
        ;

    WEnd
EndFunc   ;==>_main

Func _my_func()
    While 1
        If _IsInternetConnected() = 0 Then
            MsgBox(0, "Alert!!!", "F566 Disconnected!!!")
            ExitLoop
        ElseIf _IsInternetConnected() = 1 Then
            MsgBox(0, "Alert!!!", "F566 Connected!!!")
            ExitLoop
        EndIf
    WEnd
EndFunc   ;==>_my_func

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then
        Return SetError(1, 0, False)
    EndIf
    Return $aReturn[0] = 0
EndFunc   ;==>_IsInternetConnected

 

Edited by mLipok
some script correction

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

yes thats all, i removed exit command

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Posted
  On 4/28/2015 at 7:37 AM, mLipok said:

I think it can be a good example:

_main()

Func _main()
    While 1
        ; here main loop
        ;
        ;
        _my_func()
        ;
        ;

    WEnd
EndFunc   ;==>_main

Func _my_func()
    While 1
        If _IsInternetConnected() = 0 Then
            MsgBox(0, "Alert!!!", "F566 Disconnected!!!")
        ElseIf _IsInternetConnected() = 1 Then
            MsgBox(0, "Alert!!!", "F566 Connected!!!")
            ExitLoop
        EndIf
    WEnd
EndFunc   ;==>_my_func

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then
        Return SetError(1, 0, False)
    EndIf
    Return $aReturn[0] = 0
EndFunc   ;==>_IsInternetConnected

 

​hi I tried it still the same, my wireless connection is connected, messgebox keeps popping up

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Posted

Did you saw my modified example ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 4/28/2015 at 7:35 AM, JohnOne said:

 

While 1
    If _IsInternetConnected() = 0 Then
        MsgBox(0, "Alert!!!", "F566 Disconnected!!!")
    EndIf
WEnd

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then
        Return SetError(1, 0, False)
    EndIf
    Return $aReturn[0] = 0
EndFunc   ;==>_IsInternetConnected

 

 

​its working, but is it possible to exitloop without exiting the whole script?? is there another way?

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Posted
  On 4/28/2015 at 7:51 AM, mLipok said:

Did you saw my modified example ?

​yes nothing has change, msgbox keeps poping up because my wireless is connected...

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Posted (edited)

 

 

 

Try This

Local $IsConnected=0
While 1 
If $IsConnected<>_IsInternetConnected() Then 
$IsConnected=_IsInternetConnected()
    If $IsConnected = 0 Then
        MsgBox(0, "Alert!!!", "F566 Disconnected!!!")
    ElseIf $IsConnected = 1 Then
        MsgBox(0, "Alert!!!", "F566 Connected!!!")
    EndIf 
EndIf
WEnd

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then
        Return SetError(1, 0, False)
    EndIf
    Return $aReturn[0] = 0
EndFunc   ;==>_IsInternetConnected
Edited by sdfaheemuddin
Posted

That wrapper function is basically _WinAPI_IsInternetConnected(), so no need for outdated code anymore!

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

thanks for the info I have no idea those latest code exist.

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Posted

@sdfaheemuddin

thanks for this good example of yours, this is what im trying to make. Problem solved

@ALL

thank you for your help...

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

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
  • Recently Browsing   0 members

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