Internet Explorer上的SendMessage user32dll

我的桌面上有一个Internet Explorer页面。 网页的名称是TEST。 使用user32.dll中的FindWindow(),我可以在窗口上获得一个处理程序。 在这个页面中,我有一个名为Go和I 2的文本框,名为Name和Surname。 如何在网页上写下我的名字和姓氏,然后点击进入以编程方式进行? 谢谢

更新外部窗口的常规方法( WM_SETTEXT等)将无法工作,因为IE中的表单组件不是库存窗口,而是由IE本身呈现。

要操纵它们,您需要通过DOM调用(或使用WaitN之类的东西 )。

 using mshtml; //.net ref microsoft.mshtml using SHDocVw; //com ref `microsoft internet controls` + change ref to no embed interop int HWND = 0x001C0C10; //your IE foreach(InternetExplorer ie in new ShellWindowsClass()) { //find the instance if (ie.HWND == HWND) { //get doc HTMLDocument doc = (HTMLDocument)ie.Document; doc.getElementsByName("name").item(0).value = "bob"; doc.getElementsByName("surname").item(0).value = "smith"; doc.getElementsByName("go").item(0).click(); } } 

我不确定您使用Win32(user32.dll)实际可以提出的问题,但是如果您尝试与Web服务器交互,那么您可以根据需要使用httprequest和httpresponse类来获取GET和POST变量。

 HttpWebRequest testRequest = (HttpWebRequest)WebRequest.Create("http://....."); HttpWebResponse testResponse = (HttpWebResponse)testRequest.GetResponse(); string responseStatus = testResponse.StatusCode.ToString(); testResponse.Close(); http://msdn.microsoft.com/en-us/library/system.web.httprequest.aspx http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx 

如果您要测试或回复一组标准事件,那么您可能需要查看Fiddler

 http://www.fiddler2.com/fiddler2/