Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MafiaspilletBot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("http://mafiaspillet.no/");
webBrowser1.ScriptErrorsSuppressed = true;
}
private void button1_Click(object sender, EventArgs e)
{
SendData();
}
private void SendData()
{
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("brukernavn")[0].SetAttribute("value", textBox2.Text);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("passord")[0].SetAttribute("value", textBox1.Text);
System.Threading.Thread.Sleep(5000);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("login_buton")[0].InvokeMember("click");
System.Threading.Thread.Sleep(10000);
DoKrims();
}
private void DoKrims()
{
webBrowser1.Navigate("http://mafiaspillet.no/kriminalitet3.php");
System.Threading.Thread.Sleep(10000);
webBrowser1.Document.GetElementById("submit").InvokeMember("click");
}
}
}
But everytime I run it and fill in the textBox1
and textBox2 and submit them throu
gh the application the whole window just stop working. Is there anything in my code that can make this problem or is there anything I can do to get rid of this problem? Also, I've never worked with c#, this is the first I've made and done in c# as I thought it would be fun to learn c#. Anyways the site that is going to be loaded uses a lot of javascript and i couldn't find a way to let the webBrowser1
use them, so I used webBrowser1.ScriptErrorsSuppressed = true;
to ignore the error messages.