This is an example how to embed and control WebBrowser control.
I suppose now no need for an external library.
Gui, Show, w800 h600 Center, WebControl
hWnd := WinExist( "WebControl" )
CLSID_WebBrowser := "{8856F961-340A-11D0-A96B-00C04FD705A2}"
VarSetCapacity(IID_IWebBrowser2, 16)
;Encode 128bit IID_IWebBrowser2
EncodeInteger(&IID_IWebBrowser2 , 0xD30C1661)
EncodeInteger(&IID_IWebBrowser2 + 4, 0xCDAF | 0x11D0 << 16)
EncodeInteger(&IID_IWebBrowser2 + 8, 0x8A | 0x3E << 8 | 0x00 << 16 | 0xC0 << 24)
EncodeInteger(&IID_IWebBrowser2 +12, 0x4F | 0xC9 << 8 | 0xE2 << 16 | 0x6E << 24)
hModule := DllCall("LoadLibrary", "str", "atl.dll")
DllCall("atl\AtlAxWinInit")
hCtrl := DllCall("CreateWindowEx"
, "Uint", 0x200 ; WS_EX_CLIENTEDGE
, "str", "AtlAxWin" ; ClassName
, "Uint", &CLSID_WebBrowser ; WindowName
, "Uint", 0x10000000 | 0x40000000 ; WS_VISIBLE | WS_CHILD
, "int", 0 ; Left
, "int", 0 ; Top
, "int", 800 ; Width
, "int", 600 ; Height
, "Uint", hWnd
, "Uint", 0
, "Uint", 0
, "Uint", 0)
; Obtain IUnknown Interface
DllCall("atl\AtlAxGetControl", "Uint", hCtrl, "UintP", ppunk)
; Obtain IWebBrowser2 Interface
DllCall(DecodeInteger(DecodeInteger(ppunk) + 4*0) ; QueryInterface
, "Uint", ppunk
, "Uint", &IID_IWebBrowser2
, "UintP", ppwb)
DllCall(DecodeInteger(DecodeInteger(ppunk) + 4*2) ; Release
, "Uint", ppunk)
pwb := DecodeInteger(ppwb)
sUrl := "http://www.autohotkey.com/"
VarSetCapacity(wUrl, StrLen(sUrl) * 2 + 2)
Unicode(sUrl, wUrl)
sUrl1 := "http://www.autohotkey.com/forum/"
VarSetCapacity(wUrl1, StrLen(sUrl1) * 2 + 2)
Unicode(sUrl1, wUrl1)
; VARIANT
VarSetCapacity(var, 8 * 2, 0)
DllCall(DecodeInteger(pwb + 4*11) ; Navigate
, "Uint", ppwb
, "Uint", &wUrl
, "Uint", &var
, "Uint", &var
, "Uint", &var
, "Uint", &var)
Sleep, 5000
DllCall(DecodeInteger(pwb + 4*11) ; Navigate
, "Uint", ppwb
, "Uint", &wUrl1
, "Uint", &var
, "Uint", &var
, "Uint", &var
, "Uint", &var)
Sleep, 5000
DllCall(DecodeInteger(pwb + 4*7) ; GoBack
, "Uint", ppwb)
Sleep, 3000
DllCall(DecodeInteger(pwb + 4*8) ; GoForward
, "Uint", ppwb)
Sleep, 2000
DllCall(DecodeInteger(pwb + 4*2) ; Release
, "Uint", ppwb)
DllCall("FreeLibary", "Uint", hModule)
MsgBox, DONE
Unicode(ByRef sString, ByRef wString)
{
DllCall("MultiByteToWideChar"
, "Uint", 0
, "Uint", 0
, "Uint", &sString
, "int", -1
, "Uint", &wString
, "int", StrLen(sString) + 1)
}
DecodeInteger(ref)
{
DllCall("ntdll\RtlMoveMemory", "UintP", val, "Uint", ref, "Uint", 4)
Return val
}
EncodeInteger(ref, val)
{
DllCall("ntdll\RtlFillMemoryUlong", "Uint", ref, "Uint", 4, "Uint", val)
}