贴一下代码
private IHTMLSelectElement getSelectElement(IHTMLDocument2 document, string id)
{
var obj = (document as IHTMLDocument3).getElementById(id) as IHTMLSelectElement;
if (obj == null)
{
IHTMLFramesCollection2 frames = (IHTMLFramesCollection2)document.frames;
for (int i = 0; i < frames.length; i++)
{
try
{
IHTMLWindow2 frame = frames.item(i) as IHTMLWindow2;
IHTMLDocument2 frameDoc = frame.document;
obj = (frameDoc as IHTMLDocument3).getElementById(id) as IHTMLSelectElement;
if (obj != null)
{
break;
}
}
catch
{
}
}
}
return obj;
}}}
private IHTMLInputButtonElSHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
string filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
string url = ie.LocationURL.ToUpper();
//地址匹配 getRegQuery
//if (url.IndexOf("GETREGQUERY") >= 0)
if (isLockUrl(url))
{
IHTMLDocument2 document = ie.Document as IHTMLDocument2;
while (document.readyState != "complete")
{
Thread.Sleep(500);
}
//业务类型
string gnid = "";
var gnidObj = getSelectElement(document, "gnid");
if (gnidObj != null)
{
gnid = gnidObj.value;
//默认设置
//身份证明号码
var sfzmhmObj = getInputTextElement(document, "sfzmhm");
if (sfzmhmObj != null)
{
sfzmhmObj.readOnly = false;
}
//号牌种类
var hpzlObj = getSelectElement(document, "hpzl");
if (hpzlObj != null)
{
}
var hpzl1Obj = getSelectElement(document, "hpzl1");
if (hpzl1Obj != null)
{
}
//号牌号码
var hphmObj = getInputTextElement(document, "hphm");
if (hphmObj != null)
{
hphmObj.readOnly = false;
}
}
}