List of usage examples for org.eclipse.swt.ole.win32 OleControlSite doVerb
public int doVerb(int verb)
From source file:GetEventsFromIE.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); OleControlSite controlSite; try {// w w w . j av a2 s . c om OleFrame frame = new OleFrame(shell, SWT.NONE); controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer"); controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); } catch (SWTError e) { System.out.println("Unable to open activeX control"); return; } shell.open(); // IWebBrowser final OleAutomation webBrowser = new OleAutomation(controlSite); // When a new document is loaded, access the document object for the new // page. int DownloadComplete = 104; controlSite.addEventListener(DownloadComplete, new OleListener() { public void handleEvent(OleEvent event) { int[] htmlDocumentID = webBrowser.getIDsOfNames(new String[] { "Document" }); if (htmlDocumentID == null) return; Variant pVarResult = webBrowser.getProperty(htmlDocumentID[0]); if (pVarResult == null || pVarResult.getType() == 0) return; // IHTMLDocument2 OleAutomation htmlDocument = pVarResult.getAutomation(); // Request to be notified of click, double click and key down events EventDispatch myDispatch = new EventDispatch(EventDispatch.onclick); IDispatch idispatch = new IDispatch(myDispatch.getAddress()); Variant dispatch = new Variant(idispatch); htmlDocument.setProperty(EventDispatch.onclick, dispatch); myDispatch = new EventDispatch(EventDispatch.ondblclick); idispatch = new IDispatch(myDispatch.getAddress()); dispatch = new Variant(idispatch); htmlDocument.setProperty(EventDispatch.ondblclick, dispatch); myDispatch = new EventDispatch(EventDispatch.onkeydown); idispatch = new IDispatch(myDispatch.getAddress()); dispatch = new Variant(idispatch); htmlDocument.setProperty(EventDispatch.onkeydown, dispatch); // Remember to release OleAutomation Object htmlDocument.dispose(); } }); // Navigate to a web site int[] ids = webBrowser.getIDsOfNames(new String[] { "Navigate", "URL" }); Variant[] rgvarg = new Variant[] { new Variant("http://www.google.com") }; int[] rgdispidNamedArgs = new int[] { ids[1] }; webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // Remember to release OleAutomation Object webBrowser.dispose(); display.dispose(); }