Created
March 21, 2015 11:55
-
-
Save Netros64/51e33cac0fcda853fae8 to your computer and use it in GitHub Desktop.
Bassam Netros Connector.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By Bassam Netros | |
// This is an old code and needs more ... | |
using System; | |
using System.Windows.Forms; | |
namespace WirlessAutoConnect | |
{ | |
public class Connector | |
{ | |
public Connector() | |
{ | |
} | |
WebBrowser w = new WebBrowser(); | |
public bool IsConnected() | |
{ | |
try | |
{ | |
System.Net.WebClient ww = new System.Net.WebClient(); | |
string s = ww.DownloadString("http://10.5.50.1/status"); | |
return s.IndexOf("log off") > -1; | |
} | |
catch (Exception) | |
{ | |
return false; | |
} | |
} | |
public void TryConnect() | |
{ | |
if (IsConnected()) return; | |
w.DocumentCompleted += (ss, ee) => { | |
w.Document.InvokeScript("javascript:document.login.username.value='User';document.login.password.value='PassWord';doLogin();"); | |
return; | |
}; | |
w.Navigate("http://10.5.50.1/login"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment