Skip to content

Instantly share code, notes, and snippets.

@Netros64
Created March 21, 2015 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Netros64/51e33cac0fcda853fae8 to your computer and use it in GitHub Desktop.
Save Netros64/51e33cac0fcda853fae8 to your computer and use it in GitHub Desktop.
Bassam Netros Connector.cs
// 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