public void MatchWeb() { IEOperateCore ieCore = new IEOperateCore("http://psgpms.chinasofti.com/main.jsp"); HTMLFrameElementClass iframe = ieCore.GetInputElementByID <HTMLFrameElementClass>("ManagerTopFrame"); IHTMLDocument2 doc = iframe.contentWindow.document; HTMLBodyClass bodyClass = (HTMLBodyClass)doc.body; IHTMLElementCollection aLinkElementCollection = bodyClass.getElementsByTagName("a"); foreach (HTMLAnchorElementClass item in aLinkElementCollection) { if (item.title.Equals("退出系统")) { item.click(); break; } } IntPtr ieDialogWindowHWND = ieCore.FindWindow(null, "来自网页的消息"); Thread.Sleep(2000); IntPtr childHwnd = Win32.FindWindowEx(ieDialogWindowHWND, IntPtr.Zero, null, "取消"); //获得查询按钮的句柄 if (childHwnd != IntPtr.Zero) { Win32.SendMessage(childHwnd, Win32.BM_CLICK, IntPtr.Zero, IntPtr.Zero);//发送点击按钮的消息 } }
public void CaptureTableData() { StringBuilder buffer = new StringBuilder(); IEOperateCore ieCore = new IEOperateCore("http://psgpms.chinasofti.com/main.jsp"); HTMLFrameElementClass iframe = ieCore.GetInputElementByID <HTMLFrameElementClass>("mainFrame"); IHTMLDocument2 doc = iframe.contentWindow.document; HTMLBodyClass bodyClass = (HTMLBodyClass)doc.body; IHTMLElementCollection tableElementCollection = bodyClass.getElementsByTagName("table"); foreach (HTMLTableClass table in tableElementCollection) { if (null != table.id && table.id.Equals("rossTableId_TASK")) { foreach (HTMLTableRowClass row in table.rows) { foreach (HTMLTableCellClass cell in row.cells) { if (null != cell.innerText) { buffer.Append(cell.innerText + " "); } } buffer.Append("/r/n"); } break; } } }
public HTMLTableClass FindTableFromDocument(HTMLDocument doc, string tableId) { HTMLTableClass findTable = null; HTMLBodyClass bodyClass = (HTMLBodyClass)doc.body; IHTMLElementCollection tableElementCollection = bodyClass.getElementsByTagName("table"); foreach (HTMLTableClass table in tableElementCollection) { if (null != table.id && table.id.Equals(tableId)) { findTable = table; break; } } return(findTable); }