Jump to content

Network


Recommended Posts

I am not a good coder at all.......... and I know why my current code isn't working but not to sure how to get it working the way I want it to work so... I am hoping someone can help me with this :D

I want my script to detect when the user is idle and than it will shut off the connection and when it detects the user has come back it will ask them if they want their connection turned back on.

#include <NetCC.au3>
#include <Timers.au3>
Opt("TrayMenuMode",1)

TrayTip("Hello " & @UserName , "Internet Guard Dog" , 2)

$Connection = 1
While 1
    _Idle(1000 * 30)
WEnd

Func _Idle($iSleep)
    If _Timer_GetIdleTime() >= $iSleep Then     
        $ShutOff = MsgBox(20, "Warning!" , "Do you want to shut off your connection." , 10)
        Select
            Case $ShutOff = 6 ;Yes
                TrayTip("Connection..." , "connection being shut off..." , 2)
                _NetCC("ALL", 0)
                $Connection = 0
                TrayTip("")
            Case $ShutOff = 7 ;No
        EndSelect
    Else
        If $Connection = 0 Then
        $TurnOn = MsgBox(4 , "Welcome Back!" , "Do you want to turn on your connection." , 10)
        Select
            Case $TurnOn = 6 ;Yes
                TrayTip("Connection..." , "connection being turned on..." , 2)
                _NetCC("ALL" , 1)
                TrayTip("")
                $Connection = 1
            Case $TurnOn = 7 ;No
        EndSelect
    EndIf
EndIf
EndFunc

It basically already works but it will keep looping "MsgBox(4 , "Welcome Back!" , "Do you want to turn on your connection." , 10)" every time the user does something...

Edited by SkellySoul
Link to comment
Share on other sites

Hello.

Its looks normal 2 me cause in Case $ShutOff = 6 ;Yes you send the vvalue of $connectionn to 0 and then you check $connection's value in order to display the welcome back msg,so the script will keep display the msg as long $connection is 0

Link to comment
Share on other sites

I made a few changes but i think it works,just look the ifs.

hope it helps

#include <Timers.au3>
Opt("TrayMenuMode",1)

TrayTip("Hello " & @UserName , "Internet Guard Dog" , 2)

$Connection = 1
While 1
    _Idle(1000 * 6)
WEnd

Func _Idle($iSleep)
    If $Connection = 1 AND _Timer_GetIdleTime() >= $iSleep Then  
        $ShutOff = MsgBox(20, "Warning!" , "Do you want to shut off your connection." , 10)
        Select
        Case $ShutOff = 6;Yes
                TrayTip("Connection..." , "connection being shut off..." , 2)
               ;_NetCC("ALL", 0)
              $Connection = 0
            
            Case $ShutOff = 7;No
        EndSelect
    Else
        If $Connection = 0 and _Timer_GetIdleTime() <= 3 Then
        $TurnOn = MsgBox(4 , "Welcome Back!" , "Do you want to turn on your connection." , 10)
        $Connection = 1
        Select
            Case $TurnOn = 6;Yes
                TrayTip("Connection..." , "connection being turned on..." , 2)
              ; _NetCC("ALL" , 1)
               
                $Connection = 1
            Case $TurnOn = 7;No
        EndSelect
    EndIf
EndIf
EndFunc
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...