![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
Code: Select all
#NoEnv
SetBatchLines, -1
; Ausgabe in die Datei EventMon.txt
LogFilePath := A_ScriptDir . "\EventMon.txt"
LogFileObject := FileOpen(LogFilePath, "w")
EventMonitor.FileObject := LogFileObject
; Aus der AHK Hilfe
Gui Add, Edit, w930 r1 vURL, http://ahkscript.org/boards/
Gui Add, Button, x+6 yp w44 Default, Go
Gui Add, ActiveX, xm w980 h640 vWB, Shell.Explorer
ComObjConnect(WB, EventMonitor) ; Connect events to the EventMonitor class object.
Gui, Show, , Event Monitor
; Continue on to load the initial page:
ButtonGo:
Gui Submit, NoHide
WB.Navigate(URL)
Return
; ----------------------------------------------------------------------------------------------------------------------
GuiClose:
If IsObject(LogFileObject) {
LogFileObject.CLose()
Run, Notepad.exe "%LogFilePath%", %A_ScriptDir%
}
ExitApp
; ======================================================================================================================
; ActiveX / COM Event Monitor
; ======================================================================================================================
Class EventMonitor Extends EventMonitor_Base {
; If you set FileObject to the handle to an open file, all output will be written into this file.
; Otherwise, output will be send to the debugger (if any) per OutputDebug.
; Wenn in FileObject das 'Handle' einer zum Schreiben geöffneten Datei abgelegt wird, werden die Ausgaben in diese
; Datei geschrieben.
; Anderenfalls werden die Ausgaben per OutputDebug an den Debugger gesendet, falls einer läuft.
Static FileObject := 0
}
Class EventMonitor_Base {
__Call(Func, Params*) {
; http://www.ahkscript.org/docs/commands/ComObjType.htm
Static VT_BYREF := 16384
Static ComTypes := {0: "VT_EMPTY", 1: "VT_NULL", 2: "VT_I2", 3: "VT_I4", 4: "VT_R4", 5: "VT_R8", 6: "VT_CY"
, 7: "VT_DATE", 8: "VT_BSTR", 9: "VT_DISPATCH", 10: "VT_ERROR", 11: "VT_BOOL"
, 12: "VT_VARIANT", 13: "VT_UNKNOWN", 14: "VT_DECIMAL", 16: "VT_I1", 17: "VT_UI1"
, 18: "VT_UI2", 19: "VT_UI4", 20: "VT_I8", 21: "VT_UI8", 22: "VT_INT", 23: "VT_UINT"
, 36: "VT_RECORD", 8192: "VT_ARRAY", 16384: "VT_BYREF"}
Msg := "Event: " . Func . " >>> Params = " . Params.MaxIndex() . " :"
For Index, Param In Params {
ParamOut := Param
If IsObject(Param) {
OutType := ""
ComType := ComObjType(Param)
If (ComType > VT_BYREF) {
ComType -= VT_BYREF
OutType := ComTypes[VT_BYREF] . "->"
}
OutType .= ComTypes.HasKey(ComType) ? ComTypes[ComType] : ComTYpe
OutName := ComObjType(Param, "Name")
ParamOut := OutName ? "OBJNAME: " . OutName : "OBJTYPE: " . OutType
}
Msg .= (Index = 1 ? " " : " - ") . ParamOut
}
If (IsObject(This.FileObject))
This.FileObject.Write(Msg . "`r`n")
Else
OutputDebug, %Msg%
}
}