Jump to content

How to log every visited website


Recommended Posts

I try to write a script to monitor all websites visited with IE on a PC.

I'd like to get a log file like :

21:03:33 http://www.cyberliege.be/DIVERS/pages_services/radios.shtml
21:03:40 http://www.immo2000jemeppe.be/
21:04:00 http://www.ebay.com/

Here is some code... but I don't know how to get $obj variable as soon I visit a new website.

If $obj.document.url <> $temp Then
$temp = $obj.document.url
$file = FileOpen("test.txt", 1)
FileWrite($file, @HOUR & ":" & @MIN & ":" & @SEC & " "& $obj.document.url & @CRLF)
FileClose($file)
EndIf

Could you help me to develop this script ?

Link to comment
Share on other sites

Here is my complete code. It works but program exits if I quit IE or when I open a second IE window.... Could you help me to solve this problem ?

#include <ie.au3>
Dim $Win_hWnd,$IE_hWnd
Dim $obj,$oForm
Dim $Ctrl_List
Dim $n
Dim $temp
$temp = ""
While 1
    $Win_hWnd = WinGetHandle("")
    $Ctrl_List = WinGetClassList($Win_hWnd)
    If Not @error And StringInStr($Ctrl_List,"Internet Explorer_Server" & @LF) Then
        $n = 1
        While 1
            $IE_hWnd = ControlGetHandle($Win_hWnd,"","Internet Explorer_Server" & $n)
            If @error Then ExitLoop
                If ControlCommand($Win_hWnd,"","Internet Explorer_Server" & $n,"IsVisible","") Then
                    $obj = _ObjGetFromHWND($IE_hWnd)
                    If IsObj($obj) Then
                        If $obj.document.url <> $temp Then
                            $temp = $obj.document.url
                            $file = FileOpen("test.txt", 1)
                            FileWrite($file, @HOUR & ":" & @MIN & ":" & @SEC & " "& $obj.document.url & @CRLF)
                            FileClose($file)
                        EndIf
                        Sleep(100)
                    EndIf
                EndIf
            $n += 1
        WEnd
    EndIf
WEnd




Func _ObjGetFromHWND(ByRef $hWin)
    DLLCall("ole32.dll","int","CoInitialize","ptr",0)
    If @error Then Return SetError(@error,@extended,0)

    Local Const $WM_HTML_GETOBJECT = _RegisterWindowMessage("WM_HTML_GETOBJECT")
    If @error Then Return SetError(@error,@extended,0)
    
    Local Const $SMTO_ABORTIFHUNG = 0x0002
    Local $lResult, $typUUID, $aRet, $oIE

    _SendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $lResult)
    If @error Then Return SetError(@error,@extended,0)

    $typUUID = DLLStructCreate("int;short;short;byte[8]")
    DLLStructSetData($typUUID,1,0x626FC520)
    DLLStructSetData($typUUID,2,0xA41E)
    DLLStructSetData($typUUID,3,0x11CF)
    DLLStructSetData($typUUID,4,0xA7,1)
    DLLStructSetData($typUUID,4,0x31,2)
    DLLStructSetData($typUUID,4,0x0,3)
    DLLStructSetData($typUUID,4,0xA0,4)
    DLLStructSetData($typUUID,4,0xC9,5)
    DLLStructSetData($typUUID,4,0x8,6)
    DLLStructSetData($typUUID,4,0x26,7)
    DLLStructSetData($typUUID,4,0x37,8)

    $aRet = DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, _
            "ptr", DLLStructGetPtr($typUUID), "int", 0, "idispatch_ptr", "")
    If @error Then Return SetError(@error,@extended,0)

    If Not IsObj($aRet[4]) Then Return SetError(1,@extended,0)

    $oIE = $aRet[4].Script()
    Return $oIE
EndFunc

Func _RegisterWindowMessage($sMsg)
    Local $aRet = DllCall("user32.dll", "int", "RegisterWindowMessage", "str", $sMsg)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aRet[0]
EndFunc

Func _SendMessageTimeout($hWnd, $msg, $wParam, $lParam, $nFlags, $nTimeout, ByRef $vOut, $r = 0, $t1 = "int", $t2 = "int")
    Local $aRet = DllCall("user32.dll", "long", "SendMessageTimeout", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam, "int", $nFlags, "int", $nTimeout, "int_ptr", "")
    If @error Then
        $vOut = 0
        Return SetError(@error, @extended, 0)
    EndIf
    $vOut = $aRet[7]
    If $r >= 0 And $r <= 4 Then Return $aRet[$r]
    Return $aRet
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...