Here is a repost of my sample code:
#NoEnv SetBatchLines, -1 SetWinDelay, 0 ; Load cwebpage.dll cwebpageHandle := DllCall("LoadLibrary", "str", "cwebpage.dll") ; Exit handler OnExit, Cleanup ; Create menu Menu, browserMenu, Add, Back Menu, browserMenu, Add, Forward Menu, browserMenu, Add, Refresh Menu, browserMenu, Add, Stop Menu, browserMenu, Add, Home Menu, browserMenu, Add, Search ; Parent window Gui, 1: Add, Button, y8 x0 w50 gBack, Back Gui, 1: Add, Button, y8 x50 w50 gBack, Forward Gui, 1: Add, Button, y8 x100 w50 gRefresh, Refresh Gui, 1: Add, Button, y8 x150 w50 gStop, Stop Gui, 1: Add, Button, y8 x200 w50 gHome, Home Gui, 1: Add, Button, y8 x250 w50 gSearch, Search Gui, 1: Add, Button, y370 x0 w150 gGoExample, Open example html Gui, 1: Add, Button, y370 x150 w150 gGoAHKCHM, Open AHK chm Gui, 1: Add, Button, y370 x300 w150 gGoAHKHome, Go to AHK homepage Gui, 1: Show, w600 h400, Internet Explorer container in AHK with cwebpage.dll WinGet, mainGuiHandle, ID, A ; Child window for Browser object Gui, 2: Margin, 0, 0 Gui, 2: +ToolWindow -Caption +Border Gui, 2: Show, w590 h320 WinGet, browserGuiHandle, ID, A ; Set as child window to main gui Gui, 2: +LastFound DllCall("SetParent", "uint", WinExist(), "uint", mainGuiHandle) ; Create the Browser object res := DLLCall("cwebpage\EmbedBrowserObject", "uint", browserGuiHandle) If (res != 0 Or ErrorLevel != 0) ; error Goto, Cleanup ; Position the Browser "control" in the Gui WinMove, ahk_id %browserGuiHandle%, , 4, 40 ; Load welcome html Gosub, GoExample ; Monitor for right clicks on browser control ; WM_CONTEXTMENU ; 0x7B OnMessage(0x7B, "Web_WM_CONTEXTMENU") Return ; *** Routines: ; Browser control rightclick Web_WM_CONTEXTMENU(wParam, lParam) { Menu, browserMenu, Show } Return ; Browser control actions Back: res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 0) Return Forward: res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 1) Return Home: res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 2) Return Search: res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 3) Return Refresh: res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 4) Return Stop: res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 5) Return ; Examples ; Load welcome/example html GoExample: HTML2Load = ( <html><head><title>HTML Template</title></head><body> Welcome to the <a href="http://www.codeproject.com/com/cwebpage.asp"> cwebpage.dll</a> browser control embedded into an AutoHotkey GUI <ol><li>Pressing the <b>Open example html</b> button will load some example html <li>Pressing the <b>Open AHK chm</b> button will load the startpage of the AutoHotkey chm helpfile locally on your computer. <font color="green"><b>Cwebpage.dll can open and navigate in chm-files too!</b></font> <li>Pressing the <b>Go to AHK homepage</b> button will load the AutoHotkey homepage online <li>Pressing the <b>Open welcome html</b> button will reload this page</ol> You can control the browser object with the top buttons and the context menu... <font color="red"><b>Enjoy!</b></font>... </body></html> ) Gosub, LoadHTML Return GoAHKCHM: URL2Load = its:%A_ProgramFiles%\AutoHotkey\AutoHotkey.chm::docs\AutoHotkey.htm Gosub, LoadURL Return GoAHKHome: URL2Load = http://www.autohotkey.com Gosub, LoadURL Return ; Load URL LoadURL: res := DLLCall("cwebpage\DisplayHTMLPage" , "uint", browserGuiHandle , "str", URL2Load) If (res != 0 Or ErrorLevel != 0) ; error Goto, Cleanup URL2Load = Return ; Load HTML LoadHTML: res := DLLCall("cwebpage\DisplayHTMLStr" , "uint", browserGuiHandle , "str", HTML2Load) If (res != 0 Or ErrorLevel != 0) ; error Goto, Cleanup HTML2Load = Return ; Cleanup and exit Cleanup: GuiEscape: GuiClose: DLLCall("cwebpage\UnEmbedBrowserObject", "uint", browserGuiHandle) DllCall("FreeLibrary", "uint", cwebpageHandle) ExitApp Return
You should not use this one, though... Deprecated. Use COM/IE instead.
HTH