Jump to content

NetTray


Pakku
 Share

Recommended Posts

Hi all,

Wow it's been a while since I posted my last post here on the AutoIt forum.

Well here we go, what have I done: I (at least I think) improved GUINetCC (credtis for Tlem) by taking the GUI to the system tray.

Here at the Twente Uneversity (the Netherlands), wireless does a little strange sometimes and then I need to restart my NIC. IMO a system tray thingy would be more usefull than.

The code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>

#include <NetCC.au3>

Opt("TrayMenuMode",1)

$action = TrayCreateMenu("Actions")
$on = TrayCreateItem("Turn ON",$action)
$off = TrayCreateItem("Turn OFF",$action)
$restart = TrayCreateItem("Restart",$action)

$connection = TrayCreateMenu("Connection")
Dim $list = _NetCCGetList()
Dim $connectionitem[$list[0] + 1]
$connectionitem[0] = TrayCreateItem("All Connections",$connection)
TrayItemSetState($connectionitem[0],1)
Dim $selected = "All"
For $i = 1 To $list[0]
    $connectionitem[$i] = TrayCreateItem($list[$i],$connection)
Next

TrayCreateItem("")
$exit = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    If $msg = $exit Then
        Exit
    ElseIf _ArraySearch($connectionitem,$msg) <> -1 Then
        For $i = 0 to $list[0]
            TrayItemSetState($connectionitem[$i],4)
        Next
        TrayItemSetState($msg,1)
        If TrayItemGetText($msg) == "All Connections" Then
            $selected = "All"
        Else
            $selected = TrayItemGetText($msg)
        EndIf
    ElseIf $msg = $on Then
        TrayTip("Turning ON","Start turning ON",1,1)
        _on()
        TrayTip("Turning ON","Done",1,1)
    ElseIf $msg = $off Then
        TrayTip("Turning OFF","Start turning OFF",1,1)
        _off()
        TrayTip("Turning ON","Done",1,1)
    ElseIf $msg = $restart Then
        TrayTip("Restart","Start restarting",1,1)
        _off()
        _on()
        TrayTip("Restart","Done",1,1)
    EndIf
WEnd

Func _on()
    _NetCC($selected, 1)
EndFunc

Func _off()
    _NetCC($selected, 0)
EndFunc
Edited by Pakku
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...