Skip to content

Instantly share code, notes, and snippets.

@mostafahussein
Forked from Netros64/Connector.cs
Last active August 29, 2015 14:17
Show Gist options
  • Save mostafahussein/50709776fabd53773a8c to your computer and use it in GitHub Desktop.
Save mostafahussein/50709776fabd53773a8c to your computer and use it in GitHub Desktop.
// 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