我最近想使用c#.net编程的Windows程序进行自动打字,自动填充资源管理器浏览器。
我可以自动输入文字类型,但我无法自动输入'选择标记'。
我搜索过,我想我可以使用' setAttribute(" value"," selectIndexnumber")' 但是,我做得不好。资源管理器没有察觉到'变化'状态。
首先,我使用了IHTMLElement3.FireEvent(" onchange",null);调用' onchange'
但它也没有用。
和Secondely,我使用了SendKeys.Send(" {TAB}");
但它也没有用。
如何自动填充“选择标记”'好吧,没有像用户更改选择标签的问题?
请帮帮我。提前谢谢!
下面是我写的代码。
private void button3_Click(object sender,EventArgs e) {
SHDocVw.InternetExplorer browser;
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
string filename;
MessageBox.Show("shellWindows number is " + shellWindows.Count);
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if ((filename == "iexplore"))
{
browser = ie;
String myDocURL = browser.Document.url;
MessageBox.Show("this is url" + myDocURL);
if (myDocURL == "https://hankooktire.recruiter.co.kr/app/applicant/modifyResume")
{
IHTMLDocument3 ihtml3doc = (IHTMLDocument3)browser.Document;
IHTMLElement3 ihtml3ele = ihtml3doc.getElementById("jobnoticeSn") as IHTMLElement3;
IHTMLElement ihtmlele = ihtml3doc.getElementById("jobnoticeSn");
ihtmlele.setAttribute("value", "4");
IHTMLSelectElement selEle = ihtml3ele as IHTMLSelectElement;
//selEle.selectedIndex=4;
SendKeys.Send("{TAB}");
ihtml3ele.FireEvent("onchange", null);
//SendKeys.Send("{TAB}");
ihtml3doc.getElementById("jobnoticeSn").children(4).setAttribute("selected", "true");
SendKeys.Send("{TAB}");
//ihtml3doc.getElementById("jobnoticeSn").children(4).setAttribute("checked", "true");
//ihtml3doc.getElementById("jobnoticeSn").children(4).setAttribute("selectedIndex", "true");
//ihtml3doc.getElementById("jobnoticeSn").setAttribute("selected", "selected");
//ihtml3doc.getElementById("jobnoticeSn").setAttribute("value", "8130");
ihtml3doc.getElementById("name").setAttribute("value", "김준혁");
ihtml3doc.getElementById("birthday").setAttribute("value", "1989-11-18");
ihtml3doc.getElementById("man").setAttribute("checked", "true");
ihtml3doc.getElementById("email").setAttribute("value", "jjunest@gmail.com");
ihtml3doc.getElementById("password").setAttribute("value", "emfla248248");
//ihtml3doc.getElementById("password").scrollIntoView();
}
}
}
}