а приблезительный исходник есть????
Есть, но понятней будет если перетяннуть на форму комп-т "WebBrowser",
клик по прерыванию DocumentCompleted, там читай на каком документе находишся
(webBrowser1.Document.Title). Сборка mshtml это OLE объект наход-ся на вкладке COM
(Add Reference)
[codebox]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Net.Security;
namespace WinApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
object brsw = webBrowser1;
HtmlElement partEl = webBrowser1.Document.All["part_number"];
mshtml.HTMLInputElementClass partElVal = (mshtml.HTMLInputElementClass)partEl.DomElement;
HtmlElement parent = partEl.Parent.Parent;
HtmlElement qtyEl = parent.All["qty"];
mshtml.HTMLInputElementClass qtyElVal = (mshtml.HTMLInputElementClass)qtyEl.DomElement;
string partStr=null;
foreach(string str in textBox1.Text.Split('-'))
partStr+=str;
partElVal.value = partStr;
qtyElVal.value = "1";
System.Windows.Forms.HtmlDocument hDoc = webBrowser1.Document;
System.Windows.Forms.HtmlElementCollection elCol = parent.GetElementsByTagName("INPUT");
mshtml.HTMLInputElementClass elmntVal=null;
foreach (HtmlElement elmnt in elCol)
{
elmntVal = (mshtml.HTMLInputElementClass)elmnt.DomElement;
string elmName = elmnt.Name;
if (elmntVal.value == "обработать")
break;
}
elCol = webBrowser1.Document.GetElementsByTagName("FORM");
elmntVal.click();
ListViewItem partIt = new ListViewItem("1");
partIt.SubItems.Add(textBox1.Text);
listView1.Items.Add(partIt);
partIt.Tag = elCol.Count;
webBrowser1.Tag = partIt;
button1.Enabled = false;
textBox1.Enabled = false;
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
System.Windows.Forms.HtmlElementCollection elCol = null;
mshtml.HTMLInputElementClass elmntVal = null;
switch (webBrowser1.Document.Title)
{
case "Редактирование заказа/запроса" :
if (listView1.Items.Count > 0)
{
elCol = webBrowser1.Document.GetElementsByTagName("FORM");
ListViewItem partIt = (ListViewItem)webBrowser1.Tag;
HtmlElement elmnt = elCol[elCol.Count - 2];
partIt.Text = elmnt.Children[1].OuterText;
string delimStr = "\r\n";
char[] delimiter = delimStr.ToCharArray();
string[] partStr = elmnt.Children[2].OuterText.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
partIt.SubItems.Add(partStr[0]);
char[] chArr = partStr[1].ToLower().ToCharArray();
chArr[0] = Char.ToUpper(chArr[0]);
partIt.SubItems.Add(new string(chArr));
partIt.SubItems.Add("");
partIt.SubItems.Add(elmnt.Children[6].OuterText.Substring(0, elmnt.Children[6].OuterText.IndexOf('\r')));
}
button1.Enabled = true;
textBox1.Enabled = true;
break;
case "Вход в систему":
HtmlElement logEl = webBrowser1.Document.All["login"];
mshtml.HTMLInputElementClass logElVal = (mshtml.HTMLInputElementClass)logEl.DomElement;
logElVal.value = textBox2.Text;
HtmlElement pasEl = webBrowser1.Document.All["password"];
mshtml.HTMLInputElementClass pasElVal = (mshtml.HTMLInputElementClass)pasEl.DomElement;
pasElVal.value = maskedTextBox1.Text;
elCol = webBrowser1.Document.GetElementsByTagName("INPUT");
foreach (HtmlElement elmnt in elCol)
{
elmntVal = (mshtml.HTMLInputElementClass)elmnt.DomElement;
string elmName = elmnt.Name;
if (elmntVal.value == "Войти")//Войти
break;
}
elmntVal.click();
break;
case "Главное меню":
webBrowser1.Url = new Uri("твой сайт");
break;
case "Создание заказа/запроса":
elCol = webBrowser1.Document.GetElementsByTagName("INPUT");
foreach (HtmlElement elmnt in elCol)
{
elmntVal = (mshtml.HTMLInputElementClass)elmnt.DomElement;
string elmName = elmnt.Name;
if (elmntVal.value == "Создать")//Создать
break;
}
elmntVal.click();
break;//Создание заказа/запроса
}
if (webBrowser1.Document.Title == "Редактирование заказа/запроса")//
{
//"Вход в систему"
}
progressBar1.Value = 0;
}
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
progressBar1.Maximum=(int)e.MaximumProgress;
progressBar1.Value = (int)e.CurrentProgress;
}
private void Form1_Load(object sender, EventArgs e)
{
//webBrowser1.AllowNavigation = false;
webBrowser1.AllowWebBrowserDrop = false;
webBrowser1.IsWebBrowserContextMenuEnabled=false;
}
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
object brsw = webBrowser1;
}
private void button2_Click(object sender, EventArgs e)
{
if (maskedTextBox1.Text.Length == 0)
MessageBox.Show("Введи пароль!");
else
{
webBrowser1.Url = new Uri("твой сайт");
maskedTextBox1.Enabled = false;
button2.Enabled = false;
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (webBrowser1 != null)
webBrowser1.Dispose();
}
}
}
[/codebox]