Hello, could someone please see where I am missing some logic in the first block? IT should initatilize 3 sub-windows.... if you click OPEN you will see the 1,2 work... but with my 3rd seems to break when loading. Can you see where the problem is?
Code:
; ---------------·-------------- Init
; Settings
#NoEnv
SendMode Input
SetBatchLines, -1
OnExit, ByeBye
; ---------------·-------------- Includes before
#Include Gui_BrwsControl.ahk
; ---------------·--------- Variables
; ---------------·--------------- Gui
Gui, +LastFound
mgH := WinExist()
Brws_Init()
Brws_Add(mgH, 1, 0, 10, 10, 300, 400, "about:blank")
Brws_Add(mgH, 2, 0, 320, 10, 300, 400, "about:blank")
Brws_Add(mgH, 3, 0, 630, 10, 300, 400, "about:blank")
Gui, Add, Button, x10 y420 w60 h22 gB1, Open
Gui, Add, Button, y420 w60 h22 gB2, Home
Gui, Add, Button, y420 w60 h22 gB3, Info
Gui, Add, Button, y420 w60 h22 gB4, Prop
Gui, Add, Button, x320 y420 w60 h22 gB5, Open
Gui, Add, Button, y420 w60 h22 gB6, Home
Gui, Add, Button, y420 w60 h22 gB7, Info
Gui, Add, Button, y420 w60 h22 gB8, Prop
Gui, Add, Button, x630 y420 w60 h22 gB9, Open
Gui, Add, Button, y420 w60 h22 gB10, Home
Gui, Add, Button, y420 w60 h22 gB11, Info
Gui, Add, Button, y420 w60 h22 gB12, Prop
Gui, Show, w960 h480, 3 Browsercontrols?
; ---------------·-------------- Flow
;XXX
; /AutoExecute
Return
; -----------------·-------------------·-------------------·---------- Routines
B1:
Brws_LoadURL(1, "http://www.autohotkey.com/support/")
Return
B2:
Brws_GoHome(1)
Return
B3:
curT := Brws_GetTitle(1)
curU := Brws_GetUrl(1)
msgbox % curT . "`n`n" . curU
Return
B4:
Brws_Properties(1)
Return
B5:
Brws_LoadURL(2, "http://www.autohotkey.com/forum/")
Return
B6:
Brws_GoHome(2)
Return
B7:
curT := Brws_GetTitle(2)
curU := Brws_GetUrl(2)
msgbox % curT . "`n`n" . curU
Return
B8:
Brws_Properties(2)
Return
B9:
Brws_LoadURL(3, "http://www.autohotkey.com/docs/")
Return
B10:
Brws_GoHome(3)
Return
B11:
curT := Brws_GetTitle(3)
curU := Brws_GetUrl(3)
msgbox % curT . "`n`n" . curU
Return
B12:
Brws_Properties(3)
Return
; -----------------·----------- ExitApp
ByeBye:
GuiClose:
GuiEscape:
; ------- Cleanup
Brws_Cleanup(3)
ExitApp
Return
; -----------------·-------------------·-------------------·----------- Hotkeys
; -----------------·------------ Reload
; for debugging
!r::Reload
; -----------------·-------------------·-------------------·---------- Includes
;#Include XXX
; -----------------·-------------------·-------------------·--------------- End
you also need this
Code:
Brws_Init()
{
CoInitialize()
}
; mgH = main gui handle (handle of the gui to attach the control to)
; i = index (the index of the control, as number)
; t = type (default and 0: Internet Explorer, use t = 1 for Mozilla ActiveX)
; x,y,w,h = control position and size in gui
; u = url to load (default: empty page)
Brws_Add(mgH, i, t, x, y, w, h, u)
{
Global pwb1, hCtrl1, pwb2, hCtrl2
If (t=1) ; User wants Mozilla ActiveX
{
If Brws_CheckMozActiveX() ; ActiveX is installed
GUID4String(CLSID_WebBrowser, "{1339B54C-3453-11D2-93B9-000000000000}")
}
Else ; Internet Explorer
GUID4String(CLSID_WebBrowser, "{8856F961-340A-11D0-A96B-00C04FD705A2}")
GUID4String(IID_IWebBrowser2, "{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}")
hModule := DllCall("LoadLibrary", "str", "atl.dll")
DllCall(DllCall("GetProcAddress", "Uint", hModule, "str", "AtlAxWinInit"))
DllCall("FreeLibary", "Uint", hModule)
hCtrl%i% := DllCall("CreateWindowEx"
, "Uint", 0x200 ; WS_EX_CLIENTEDGE
, "str", "AtlAxWin" ; ClassName
, "str", CLSID_WebBrowser ; WindowName
, "Uint", 0x10000000 | 0x40000000 | 0x04200000 ; WS_VISIBLE | WS_CHILD | ...
, "int", x ; Left
, "int", y ; Top
, "int", w ; Width
, "int", h ; Height
, "Uint", mgH ; hWndParent
, "Uint", 0 ; hMenu
, "Uint", 0 ; hInstance
, "Uint", 0)
DllCall("atl\AtlAxGetControl", "Uint", hCtrl%i%, "UintP", punk)
pwb%i% := QueryInterface(punk, IID_IWebBrowser2)
Release(punk)
Brws_LoadURL(i, u)
Return pwb%i%
}
Brws_CheckMozActiveX()
{
Return true ; test
}
Brws_Move(i, x, y, w, h)
{
Global hCtrl1, hCtrl2
if (i=1)
thisC := hCtrl1
if (i=2)
thisC := hCtrl2
WinMove, ahk_id %thisC%, , x, y, w, h
}
Brws_LoadURL(i, u)
{
Global pwb1, pwb2
Ansi2Unicode(u, wUrl)
DllCall(VTable(pwb%i%, 11), "Uint", pwb%i%, "str", wUrl, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_GoBack(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 7), "Uint", pwb%i%)
}
Brws_GoForward(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 8), "Uint", pwb%i%)
}
Brws_GoHome(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 9), "Uint", pwb%i%)
}
Brws_GoSearch(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 10), "Uint", pwb%i%)
}
Brws_GoRefresh(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 12), "Uint", pwb%i%)
}
Brws_GoStop(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 14), "Uint", pwb%i%)
}
Brws_GetTitle(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 29), "Uint", pwb%i%, "UintP", pName)
Unicode2Ansi(pName, sName)
SysFreeString(pName)
Return sName
}
Brws_GetURL(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 30), "Uint", pwb%i%, "UintP", pUrl)
Unicode2Ansi(pUrl, sUrl)
SysFreeString(pUrl)
Return sUrl
}
Brws_Visible(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 40), "Uint", pwb%i%, "intP", bVis)
DllCall(VTable(pwb%i%, 41), "Uint", pwb%i%, "int" , bVis ^ 1)
}
Brws_Offline(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 47), "Uint", pwb%i%, "intP", bOff)
DllCall(VTable(pwb%i%, 48), "Uint", pwb%i%, "int" , bOff ^ 1)
}
Brws_Open(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 1, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_New(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 2, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_Save(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 3, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_SaveAs(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 4, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_Print(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 6, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_PrintPreview(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 7, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_PageSetup(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 8, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_Properties(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 10, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_Cut(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 11, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_Copy(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 12, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_Paste(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 13, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_SelectAll(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 17, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_Find(i)
{
Global pwb1, pwb2
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 32, "Uint", 0, "Uint", 0, "Uint", 0)
}
Brws_DoFontSize(i, s)
{
Global pwb1, pwb2
VarSetCapacity(var, 8 * 2)
EncodeInteger(&var + 0, 3)
EncodeInteger(&var + 8, s - 1)
DllCall(VTable(pwb%i%, 54), "Uint", pwb%i%, "Uint", 19, "Uint", 2, "Uint", &var, "Uint", &var)
}
Brws_InternetOptions(i)
{
CGID_MSHTML(i, 2135)
}
Brws_ViewSource(i)
{
CGID_MSHTML(i, 2139)
}
Brws_AddToFavorites(i)
{
CGID_MSHTML(i, 2261)
}
Brws_MakeDesktopShortcut(i)
{
CGID_MSHTML(i, 2266)
}
Brws_SendEMail(i)
{
CGID_MSHTML(i, 2288)
}
Brws_ClearHistory()
{
/*
GUID4String( CLSID_CUrlHistory, "{3C374A40-BAE4-11CF-BF7D-00AA006946EE}")
GUID4String(IID_IUrlHistoryStg, "{3C374A41-BAE4-11CF-BF7D-00AA006946EE}")
puh := CreateObject(CLSID_CUrlHistory, IID_IUrlHistoryStg)
DllCall(VTable(puh, 9), "Uint", puh)
DllCall(VTable(puh, 2), "Uint", puh)
*/
Brws_GetHistory(1)
}
Brws_GetHistory(bDelete = 0)
{
GUID4String( CLSID_CUrlHistory, "{3C374A40-BAE4-11CF-BF7D-00AA006946EE}")
GUID4String(IID_IUrlHistoryStg, "{3C374A41-BAE4-11CF-BF7D-00AA006946EE}")
puh := CreateObject(CLSID_CUrlHistory, IID_IUrlHistoryStg)
DllCall(VTable(puh, 7), "Uint", puh, "UintP", psu)
VarSetCapacity(var, 40)
EncodeInteger(&var, VarSetCapacity(var))
Loop
{
If DllCall(VTable(psu, 3), "Uint", psu, "Uint", 1, "Uint", &var, "Uint", 0)
Break
pUrl := DecodeInteger(&var + 4)
pTitle := DecodeInteger(&var + 8)
If !bDelete
{
Unicode2Ansi(pUrl , sUrl )
Unicode2Ansi(pTitle, sTitle)
sHistory .= sUrl . "|" . sTitle . "`n"
}
Else
DllCall(VTable(puh, 4), "Uint", puh, "Uint", pUrl, "Uint", 0)
SysFreeString(pUrl )
SysFreeString(pTitle)
}
DllCall(VTable(psu, 2), "Uint", psu)
DllCall(VTable(puh, 2), "Uint", puh)
Return sHistory
}
Brws_Cleanup(nr)
{
Loop %nr%
Release(pwb%A_Index%)
CoUninitialize()
}
CGID_MSHTML(i, nCmd, nOpt = 0)
{
Global pwb1, pwb2
GUID4String(CGID_MSHTML , "{DE4BA900-59CA-11CF-9592-444553540000}")
GUID4String(IID_IOleCommandTarget, "{B722BCCB-4E68-101B-A2BC-00AA00404770}")
pct := QueryInterface(pwb%i%, IID_IOleCommandTarget)
DllCall(VTable(pct, 4), "Uint", pct, "str", CGID_MSHTML, "Uint", nCmd, "Uint", nOpt, "Uint", 0, "Uint", 0)
Release(pct)
}
#Include CoHelper.ahk
Finally, this requires the UPDATED
CoHelper.ahk, so please re-copy it. [/url]