diff -Nur Wired Network Meter/gadget.js Wired Network MeterByTommy/gadget.js
--- Wired Network Meter/gadget.js	Thu Sep 18 17:07:12 2008
+++ Wired Network MeterByTommy/gadget.js	Wed Feb 11 15:53:58 2009
@@ -12,6 +12,12 @@
 
 var NetLib;
 var currentInterface = 0;
+/* add by tommy, 20090210 begin */
+var currentInterfaceDesc = "";
+var currentInterfaceSetting = -1;
+var nInterfaceCount = 0;
+var myCurrentInterface = 0;
+/* add by tommy, 20090210 end */
 var bytesReceived = 0;
 var bytesSent = 0;
 var lastBytesReceived = 0;
@@ -33,7 +39,7 @@
 var txtUp;
 var imgDown;
 var txtDown;
-var back = "black"; 
+var back = "black";
 var vismode = 0;
 var barup = 0;
 var bardown = 0;
@@ -70,20 +76,122 @@
 
 function onTimer()
 {
-    updateNetVars(); 
+    updateNetVars();
     refreshdisplay();
-    updateGraph(); 
+    updateGraph();
 }
 
 function initNetLib()
 {
     debugLog("initNetLib");
-    var count = NetLib.Initialize();
+    /* add by tommy, 20090210 begin */
+    /* var count = NetLib.Initialize(); */
+    nInterfaceCount = NetLib.Initialize();
+    /* add by tommy, 20090210 end */
 }
 
 function GadgetUpdate() {
 
-    ipaddress.innerText = System.Network.Wireless.address;
+    /* add by tommy, 20090210 begin */
+    /* ipaddress.innerText = System.Network.Wireless.address; */
+    /*
+    * Loop through the network connections and get IP gateway and IP address
+    */
+    var locator    = new ActiveXObject ("WbemScripting.SWbemLocator");
+    var service    = locator.ConnectServer(".");
+    var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
+    var e = new Enumerator (properties);
+    var firstip = "";
+    var firstDesc = "";
+    var lanip = "";
+    var gwip = "";
+    var firstIndex = -1;
+    var tempInterface = -1;
+    var tempInterfaceDesc = "NONE";
+    var settingInterfaceDesc = "NONE";
+    var settingInterfaceIP = "----";
+    for (;!e.atEnd();e.moveNext ())
+    {
+        var p = e.item ();
+        if (firstip == "" && p.IPAddress!=null)
+        {
+            firstip = p.IPAddress(0);
+            for (var i = 0;i < nInterfaceCount; i++)
+            {
+                if (p.Description == NetLib.Description(i))
+                {
+                    firstDesc = p.Description;
+                    firstIndex = i;
+                }
+            }
+        }
+        if (currentInterfaceSetting != -1)
+        {
+            if (p.Description == NetLib.Description(currentInterfaceSetting))
+            {
+                settingInterfaceDesc = p.Description;
+                if (p.IPAddress != null)
+                    settingInterfaceIP = p.IPAddress(0);
+                else
+                    settingInterfaceIP = "----";
+            }
+        }
+        if (p.DefaultIPGateway!=null)
+        {
+            gwip = p.DefaultIPGateway(0);
+            if (p.IPAddress!=null)
+                lanip = p.IPAddress(0);
+            if (p.Description != currentInterfaceDesc || myCurrentInterface != currentInterface)
+            {
+                for (var i = 0;i < nInterfaceCount; i++)
+                {
+                    if (p.Description == NetLib.Description(i))
+                    {
+                        tempInterfaceDesc = p.Description;
+                        tempInterface = i;
+                    }
+                }
+            }
+        }
+    }
+    if (currentInterfaceSetting != -1)
+    {
+        currentInface = currentInterfaceSetting;
+        lanip = settingInterfaceIP;
+        currentInterfaceDesc = settingInterfaceDesc;
+    }
+    else
+    {
+        if (lanip == "")
+        {
+            if (firstIndex != -1)
+            {
+                lanip = firstip;
+                currentInterfaceDesc = firstDesc;
+                currentInterface = firstIndex;
+                myCurrentInterface = currentInterface;
+            }
+        }
+        else
+        {
+            if (tempInterface != -1 && (tempInterface != currentInterface ||
+                                        currentInterfaceDesc != tempInterfaceDesc ||
+                                        myCurrentInterface != currentInterface))
+            {
+                currentInterfaceDesc = tempInterfaceDesc;
+                currentInterface = tempInterface ;
+                myCurrentInterface = currentInterface;
+            }
+        }
+    }
+
+	dcsignal = System.Network.Wireless.signalStrength;
+
+	if (dcsignal == null) { dcsignal = 0 };
+	if (dcsignal > 0)
+        lanip = System.Network.Wireless.address;
+    ipaddress.innerText = lanip + " " + currentInterface + ":" + currentInterfaceDesc.substr(0, 4 + 16 - lanip.length);
+    /* add by tommy, 20090210 end */
 	setTimeout("GadgetUpdate()", 400);
 
 }
@@ -91,26 +199,26 @@
 function initDisplay()
 {
     imgNTtextImage = background.addImageObject("wireless.png", 7, 5)
-    txtNTtextObject = background.addTextObject("Network Meter" , "Segoe UI", 12, "White", 27, 5); 
+    txtNTtextObject = background.addTextObject("Network Meter" , "Segoe UI", 12, "White", 27, 5);
     imgUp = background.addImageObject("arrow_up_green.png", 4, 52);
     imgDown = background.addImageObject("arrow_down_blue.png", 4, 63);
 }
 
 function updateNetVars()
 {
-    
+
     lastBytesReceived = bytesReceived;
     lastBytesSent = bytesSent;
-      
+
     bytesReceived = parseInt(NetLib.BytesReceived(currentInterface));
 	bytesSent = parseInt(NetLib.BytesSent(currentInterface));
-	
+
 	bytesReceivedSec = bytesReceived - lastBytesReceived;
     bytesSentSec = bytesSent - lastBytesSent;
 
     //bytesReceivedSec = 1026123;
     //bytesSentSec = 1026123;
-    
+
     if (lastBytesReceived == 0)
         bytesReceivedSec = 0;
     if (lastBytesSent  == 0)
@@ -123,11 +231,11 @@
 
 	if (receivedHist.push(bytesReceivedSec) > maxHist)
 		receivedHist.shift();
-	
+
 	if (sentHist.push(bytesSentSec) > maxHist)
 		sentHist.shift();
-	
-	
+
+
 }
 
 function terminateNetLib()
@@ -149,23 +257,23 @@
     else if (val > 10)
         return val.toFixed(2);
     else
-        return val.toFixed(3);    
+        return val.toFixed(3);
 }
 
 function formatBytes(bytes)
 {
     if (bytes > 1048576)
         return fourdigits((bytes / 1024) / 1024) + "M";
-        
+
     if (bytes > 1024)
         return fourdigits(bytes / 1024) + "K";
-        
-    return fourdigits(bytes);    
+
+    return fourdigits(bytes);
 }
 
 function refreshdisplay()
 {
-    
+
     if (vismode != 0)
     {
         txtUpBits.innerText = formatBytes(bytesSentSec)+"B/s";
@@ -211,18 +319,18 @@
 	var param="";
 	var max = 0;
 	var v_max = getMaxValue();
-	
+
 	max = scalesize*1024;
-	
+
 	if  ( (v_max > max) || (scaletype == 0) )
 	    max = v_max;
-	else 
-	    max = scalesize*1024;     
-	
+	else
+	    max = scalesize*1024;
+
 	try
     {
-    
-    
+
+
 	    if (vismode != 0)
         {
 	        if ( barup == 0 )
@@ -241,7 +349,7 @@
 	            imgbar1.src = "bargreen.png";
 	            bar1.style.width = parseInt( 50 / (barup / bytesSentSec) );
 	        }
-    	    
+
 	        if ( bardown == 0 )
 	        {
 	            imgbar2.src = "baryellow.png";
@@ -259,23 +367,23 @@
 	            bar2.style.width = parseInt( 50 / (bardown / bytesReceivedSec) );
 	        }
 	    }
-	        
-    	
+
+
 	    for (var i=0; i<maxHist; i++)
 	    {
-    		
+
 		    ub = parseInt( 30 / (max / sentHist[i]) ) ;
-		    db = parseInt( 30 / (max / receivedHist[i]) ); 
-    		
+		    db = parseInt( 30 / (max / receivedHist[i]) );
+
 		    if (ub > 30) ub = 30;
 		    if (db > 30) db = 30;
-    		
-    		
+
+
 		    if (drawstyle==1)
 		    {
 		        param =  (ub == 0) ? "m" : "l";
     	        uppath += " m " + parseInt(i+1) + ",30 " + param + " " + parseInt(i+1) + "," +parseInt(30-(ub)) + "";
-        	    
+
     	        param =  (db == 0) ? "m" : "l";
       		    downpath += " m " + parseInt(i+1) + ",30 " + param + " " + parseInt(i+1) + "," +parseInt(30-(db)) + "";
     	    }
@@ -284,14 +392,14 @@
 		        uppath += " l " + parseInt(i+1) + "," +parseInt(30-(ub));
 		        downpath += " l " + parseInt(i+1) + "," +parseInt(30-(db));
 		    }
-      		
+
   	    }
   	}
-  	catch(err) 
+  	catch(err)
 	{
 	    debugLog("updateGraph: "+err.name+" - "+err.message)
 	}
-	
+
 	uppath = uppath + " e";
 	downpath = downpath + " e";
 	downgraph.path = downpath;
@@ -302,37 +410,49 @@
 {
     debugLog("loadSettings[Main]");
     debugLog("loadSettings:Interface->"+ System.Gadget.Settings.read("interface"));
+    // add by tommy, 20090211 begin
+    /*
     currentInterface = System.Gadget.Settings.read("interface");
-    if (currentInterface == "") currentInterface=0;     
-    
+    if (currentInterface == "") currentInterface=0;
+    */
+    currentInterfaceSetting = System.Gadget.Settings.read("interface");
+    if (currentInterfaceSetting == "")
+        currentInterfaceSetting = -1;
+    if (currentInterfaceSetting == -1)
+        currentInterface = 0;
+    else
+        currentInterface = currentInterfaceSetting;
+    currentInterfaceDesc = NetLib.Description(currentInterface);
+    // add by tommy, 20090211 end
+
     debugLog("loadSettings:DrawStyle->"+ System.Gadget.Settings.read("drawstyle"));
-    drawstyle = System.Gadget.Settings.read("drawstyle");     
-    
+    drawstyle = System.Gadget.Settings.read("drawstyle");
+
     debugLog("loadSettings:ScaleType->"+ System.Gadget.Settings.read("scaletype"));
-    scaletype = System.Gadget.Settings.read("scaletype");  
-    
+    scaletype = System.Gadget.Settings.read("scaletype");
+
     debugLog("loadSettings:ScaleSize->"+ System.Gadget.Settings.read("scalesize"));
-    scalesize = System.Gadget.Settings.read("scalesize");   
-    
+    scalesize = System.Gadget.Settings.read("scalesize");
+
     debugLog("loadSettings:VisMode->"+ System.Gadget.Settings.read("vismode"));
-    vismode = System.Gadget.Settings.read("vismode");   
-    
+    vismode = System.Gadget.Settings.read("vismode");
+
     debugLog("loadSettings:barup->"+ System.Gadget.Settings.read("barup"));
-    barup = System.Gadget.Settings.read("barup") * 1024;   
-    
+    barup = System.Gadget.Settings.read("barup") * 1024;
+
     debugLog("loadSettings:bardown->"+ System.Gadget.Settings.read("bardown"));
-    bardown = System.Gadget.Settings.read("bardown") * 1024;   
-    
+    bardown = System.Gadget.Settings.read("bardown") * 1024;
+
     var b = System.Gadget.Settings.readString("background");
-	if ( b != "") back = b; else back = "black";   
-	
-	toggleVisMode();   
+	if ( b != "") back = b; else back = "black";
+
+	toggleVisMode();
 }
 
 function toggleVisMode()
 {
 	background.src = back + ".png";
-    
+
     if (vismode != 0)
     {
 	    bar1.style.visibility = "visible";
@@ -381,12 +501,12 @@
 }
 else
    {
-  ip.innerText = "No connection" 
+  ip.innerText = "No connection"
   con.src = ("/blank.png");
    }
 }
 
-function copyText() { 
+function copyText() {
 var myVar = ip.innerText;
 window.clipboardData.setData('text',myVar);
-}
\ No newline at end of file
+}
diff -Nur Wired Network Meter/settings.js Wired Network MeterByTommy/settings.js
--- Wired Network Meter/settings.js	Mon Mar 17 15:26:27 2008
+++ Wired Network MeterByTommy/settings.js	Wed Feb 11 15:49:00 2009
@@ -27,7 +27,7 @@
 function SettingsClosing(event)
 {
 	debugLog("SettingsClosing:" + event);
-	if (event.closeAction == event.Action.commit) 
+	if (event.closeAction == event.Action.commit)
 		saveSettings();
 	event.cancel = false;
 }
@@ -43,28 +43,28 @@
 function loadSettings()
 {
     debugLog("loadSettings");
-    
+
     debugLog("loadSettings:Interface->"+ System.Gadget.Settings.read("interface"));
     Interface.value = System.Gadget.Settings.read("interface");
-    
+
     debugLog("loadSettings:DrawStyle->"+ System.Gadget.Settings.read("drawstyle"));
     DrawStyle.value = System.Gadget.Settings.read("drawstyle");
-    
+
     debugLog("loadSettings:ScaleType->"+ System.Gadget.Settings.read("scaletype"));
     ScaleType.value = System.Gadget.Settings.read("scaletype");
-    
+
     debugLog("loadSettings:ScaleSize->"+ System.Gadget.Settings.read("scalesize"));
     ScaleSize.value = System.Gadget.Settings.read("scalesize");
-    
+
     debugLog("loadSettings:background->"+ System.Gadget.Settings.read("background"));
     background.value = System.Gadget.Settings.read("background");
-    
+
     debugLog("loadSettings:vismode->"+ System.Gadget.Settings.read("vismode"));
     VisMode.value = System.Gadget.Settings.read("vismode");
-    
+
     debugLog("loadSettings:barup->"+ System.Gadget.Settings.read("barup"));
-    barup.value = System.Gadget.Settings.read("barup"); 
-    
+    barup.value = System.Gadget.Settings.read("barup");
+
     debugLog("loadSettings:bardown->"+ System.Gadget.Settings.read("bardown"));
     bardown.value = System.Gadget.Settings.read("bardown");
 }
@@ -72,44 +72,47 @@
 function saveSettings()
 {
     debugLog("saveSettings");
-    
-    debugLog("saveSettings:interface->"+ Interface.value); 
+
+    debugLog("saveSettings:interface->"+ Interface.value);
     System.Gadget.Settings.write("interface", Interface.value);
-    
-    debugLog("saveSettings:drawstyle->"+ DrawStyle.value); 
+
+    debugLog("saveSettings:drawstyle->"+ DrawStyle.value);
     System.Gadget.Settings.write("drawstyle", DrawStyle.value);
-    
-    debugLog("saveSettings:scaletype->"+ ScaleType.value); 
+
+    debugLog("saveSettings:scaletype->"+ ScaleType.value);
     System.Gadget.Settings.write("scaletype", ScaleType.value);
-    
-    debugLog("saveSettings:scalesize->"+ ScaleSize.value); 
+
+    debugLog("saveSettings:scalesize->"+ ScaleSize.value);
     System.Gadget.Settings.write("scalesize", ScaleSize.value);
-    
-    debugLog("saveSettings:background->"+ background.value); 
+
+    debugLog("saveSettings:background->"+ background.value);
     System.Gadget.Settings.write("background", background.value);
-    
-    debugLog("saveSettings:vismode->"+ VisMode.value); 
+
+    debugLog("saveSettings:vismode->"+ VisMode.value);
     System.Gadget.Settings.write("vismode", VisMode.value);
-    
-    debugLog("saveSettings:barup->"+ barup.value); 
+
+    debugLog("saveSettings:barup->"+ barup.value);
     System.Gadget.Settings.write("barup", barup.value);
-    
-    debugLog("saveSettings:bardown->"+ bardown.value); 
+
+    debugLog("saveSettings:bardown->"+ bardown.value);
     System.Gadget.Settings.write("bardown", bardown.value);
 }
 
 function fillInterfaceCombo()
 {
     debugLog("fillInterfaceCombo");
-    try 
+    try
     {
+        // add by tommy, 20090211 begin
+        Interface.options[Interface.length] = new Option("-1: Automatic", -1);
+        // add by tommy, 20090211 end
         for (var i = 0;i < interfaceCount; i++)
         {
             Interface.options[Interface.length] = new Option(i + ": " + System.Gadget.document.parentWindow.NetLib.Description(i), i);
         }
     }
-	catch(err) 
+	catch(err)
 	{
 	    debugLog("fillInterfaceCombo: "+err.name+" - "+err.message)
 	}
-}
\ No newline at end of file
+}
