Coco wrote: ↑13 Jan 2016, 09:05
It seems that the argument(s) are not getting passed unless you specify a reference to a JavaScript function. A solution is to use a JavaScript function as the listener and from there call your AHK function. Something like:
Code: Select all
; Inject JavaScript
window.eval("function eventListener(listener) { return function(e) { return listener(e); }; }")
; You can dynamically specify any AHK function
window.addEventListener("mousemove", window.eventListener(Func("OnMouseMove")))
sounds like what ud classify as a "bug". now only to figure out where - in AHK or in IE. somebody who really, really, reeeeeaallllyyyy likes COM should investigate this
and additionally ull probably have to have applied
"the registry fix":
lexikos wrote: ↑24 Apr 2018, 04:51
"Gui Add, ActiveX" is not something designed for adding HTML to a GUI.
ActiveX components such as the MSIE browser control can be embedded into a GUI window
ActiveX is basically a set of patterns that controls from different developers may follow to allow programs to utilize those controls by calling standard functions. ActiveX has nothing to do with HTML.
You are using the MSIE browser control (a.k.a. the WebBrowser control), which is just one control built following ActiveX patterns. It exists entirely separate from AutoHotkey. AutoHotkey has no knowledge whatsoever of the WebBrowser control; it merely uses an ActiveX function to request the creation of a control from a given string (such as
Shell.Explorer or
https://autohotkey.com/boards/ as used in the examples). The ActiveX functions look to the registry to find how to create the control.
So the short answer is that the version of ActiveX control you get has nothing to do with the version number of AutoHotkey.
On systems with IE8 or later, the WebBrowser control operates in IE7 compatibility mode by default. Generally the document must contain something like <meta http-equiv="X-UA-Compatible" content="IE=edge"> to override this, unless you use a registry override based on whichever process name you are using (e.g. AutoHotkey.exe).
lexikos wrote: ↑25 Jan 2016, 03:38
the "IE=edge" should force Shell.Explorer to use the latest IE renderer.
It does. And then you load a different document, and it uses whatever renderer that document appears to need.
If you are displaying HTML which is not under your control, you will need to use the registry fix. Search "FixIE" for details.
lexikos wrote: ↑24 Jul 2021, 19:10
Internet Explorer 9?
Are you using Vista?
WebBrowser controls operate in IE7-compatibility mode by default, although I'm not sure how that affects the JavaScript environment. There are at least two ways around it:
- Include <meta http-equiv='X-UA-Compatible' content='IE=edge'> in the document.
- Use a registry fix (search the forum for FixIE).
lexikos wrote: ↑26 Dec 2015, 20:29
The WebBrowser control operates in IE7 mode by default. This can only be overridden within the document (with a X-UA-Compatible meta-tag) or via the registry based on your process name. Search the forum for FixIE or FEATURE_BROWSER_EMULATION.
lexikos wrote: ↑30 May 2015, 22:01
- window.eval(js) will evaluate js and give you a result, but it seems to fail fairly often if the page is in an older document mode (WB.Document.documentMode). The WebBrowser control operates in IE7 or IE5 mode by default, depending on the !DOCTYPE. You can override it with the FEATURE_BROWSER_EMULATION registry key or putting <meta http-equiv="X-UA-Compatible" content="IE=edge"> in the document.
in other words:
Code: Select all
#Requires AutoHotkey v2.0-beta.1
MyGui := Gui()
URL := MyGui.Add("Edit", "w930 r1", "https://www.autohotkey.com/boards/")
MyGui.Add("Button", "x+6 yp w44 Default", "Go").OnEvent("Click", ButtonGo)
WB := MyGui.Add("ActiveX", "xm w980 h640", "Shell.Explorer").Value
WB.silent := True
ComObjConnect(WB, WB_events) ; Connect WB's events to the WB_events class object.
MyGui.Show()
; Continue on to load the initial page:
ButtonGo()
ButtonGo(*) {
WB.Navigate(URL.Value)
}
class WB_events {
static NavigateComplete2(wb, &NewURL, OriginalComWrapper) {
URL.Value := NewURL ; Update the URL edit control.
doc := wb.document
win := doc.parentWindow
win.eval('function jsFuncFromAhkFunc(ahkFunc) { return function(arg1) { return ahkFunc(arg1); }; }')
doc.addEventListener('mouseup', win.jsFuncFromAhkFunc(OnMouseUp))
OnMouseUp(MouseEvent) {
ToolTip(
'MouseEvent.altKey:' MouseEvent.altKey '`n'
'MouseEvent.button:' MouseEvent.button '`n'
'MouseEvent.buttons:' MouseEvent.buttons '`n'
'MouseEvent.clientX:' MouseEvent.clientX '`n'
'MouseEvent.clientY:' MouseEvent.clientY '`n'
'MouseEvent.ctrlKey:' MouseEvent.ctrlKey '`n'
'MouseEvent.metaKey:' MouseEvent.metaKey '`n'
'MouseEvent.offsetX:' MouseEvent.offsetX '`n'
'MouseEvent.offsetY:' MouseEvent.offsetY '`n'
'MouseEvent.pageX:' MouseEvent.pageX '`n'
'MouseEvent.pageY:' MouseEvent.pageY '`n'
'MouseEvent.relatedTarget:' IsObject(MouseEvent.relatedTarget) '`n'
'MouseEvent.screenX:' MouseEvent.screenX '`n'
'MouseEvent.screenY:' MouseEvent.screenY '`n'
'MouseEvent.shiftKey:' MouseEvent.shiftKey '`n'
'Modifiers active(pressed/locked)?' '`n'
'Win:' MouseEvent.getModifierState('Win') '`n'
'Alt:' MouseEvent.getModifierState('Alt') '`n'
'AltGraph:' MouseEvent.getModifierState('AltGraph') '`n'
'CapsLock:' MouseEvent.getModifierState('CapsLock') '`n'
'Control:' MouseEvent.getModifierState('Control') '`n'
'Fn:' MouseEvent.getModifierState('Fn') '`n'
'FnLock:' MouseEvent.getModifierState('FnLock') '`n'
'Hyper:' MouseEvent.getModifierState('Hyper') '`n'
'Meta:' MouseEvent.getModifierState('Meta') '`n'
'NumLock:' MouseEvent.getModifierState('NumLock') '`n'
'ScrollLock:' MouseEvent.getModifierState('ScrollLock') '`n'
'Shift:' MouseEvent.getModifierState('Shift') '`n'
'Super:' MouseEvent.getModifierState('Super') '`n'
'Symbol:' MouseEvent.getModifierState('Symbol') '`n'
'SymbolLock:' MouseEvent.getModifierState('SymbolLock') '`n'
)
}
}
}
which means u could even move the function back to being a class method, with either:
Code: Select all
...
doc.addEventListener('mouseup', win.jsFuncFromAhkFunc(WB_events.OnMouseUp))
}
static OnMouseUp() {
; hidden this = MouseEvent
}
...
or
Code: Select all
...
doc.addEventListener('mouseup', win.jsFuncFromAhkFunc(WB_events.OnMouseUp.Bind(WB_events)))
}
static OnMouseUp(MouseEvent) {
}
...
which probably also answers
viewtopic.php?p=197613#p197613