C#客户端填充外部IE浏览器中网页文本(input)且不提交
//引用COM组件
//Microsoft HTML Object Library
//Microsoft Internet Controls
记得改成x86
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
string filename;
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
SetText(string.Format("Web Site : {0}", ie.LocationURL));
mshtml.IHTMLDocument2 htmlDoc = ie.Document as mshtml.IHTMLDocument2;
SetText(string.Format(" Document Snippet: {0}",
((htmlDoc != null) ? htmlDoc.body.outerHTML
: "***Failed***")));
SetText(string.Format("{0}{0}", Environment.NewLine));
mshtml.HTMLInputElementClass input;
foreach (mshtml.IHTMLElement ieElement in htmlDoc.all)
{
if (ieElement.tagName.ToUpper().Equals("INPUT"))
{
input = ((mshtml.HTMLInputElementClass)ieElement);
if (input.name == "gmfmc")
{
input.value = "****";
}
else if (input.name == "gmfnsrsbh")
{
input.value = "12300000747150428A";
}
else if (input.name == "gmfdz")
{
input.value = "北京市";
}
else if (input.name == "gmfdz")
{
input.value = "010-512011";
}
else if (input.name == "gmfkhh")
{
input.value = "北京银行";
}
else if (input.name == "gmfyhzh")
{
input.value = "132465798798";
}
else if (input.name == "gmfsjhm")
{
input.value = "18456487920";
}
else if (input.name == "gmfyxdz")
{
input.value = "sa@123.com";
}
}
}
}
}

浙公网安备 33010602011771号