如何检测用户是否Refresh
通过上下文菜单选择?当用户选择它时,该NavigateComplete2
方法不会被调用。
更重要的是,要设置自己的自定义用户代理,一种方法是挂钩BeforeNavigate2
事件方法,并且需要知道用户是否选择了刷新或导航新的 url。
任何见解将不胜感激。
这表明该方法在被选中NavigateComplete2
时不会被触发。Refresh
oWB := new WebBrowserControl("http://stackoverflow.com")
Class WebBrowserControl
{
__New(strURL) {
static WB
Gui, New, Resize
Gui, Add, ActiveX, vWB w780 h580, Shell.Explorer
Gui, show, w800 h600
ComObjConnect(WB, this)
WB.Navigate(strURL)
Loop
Sleep 10
Until (WB.readyState=4 && WB.document.readyState="complete" && !WB.busy)
Return
GuiClose:
ExitApp
}
NavigateComplete2(oParams*) {
ComObjError(false)
WB := oParams[1]
msgbox, 64, Navigate Completed
, % "WB.locationURL :`t`t" WB.locationURL "`n"
. "WB.Document.URL:`t`t" WB.Document.URL "`n"
. "windowlocation.href:`t" WB.document.parentWindow.location.href
}
BeforeNavigate2(oParams*) {
WB := oParams[8]
strURL := oParams[2]
msgbox % "Loading URL:`t`t" strURL "`n"
. "WB.locationURL :`t`t" WB.locationURL "`n"
. "WB.Document.URL:`t`t" WB.Document.URL "`n"
. "location.href:`t`t" WB.document.parentWindow.location.href "`n"
. "WB.ReadyState:`t`t" WB.readystate "`n"
. "WB.document.readystate:`t" WB.document.readystate "`n"
. "WB.Busy:`t`t`t" WB.Busy "`n"
}
}