Jump to content

Recommended Posts

Posted

Hello, :)

Check of Website Content Changes. Based on the hash value.

Button Global $ hButtonAddLink:

The website is being downloaded.
It will generate an MD5 hash.
An .ini file is created. With the link of the website and the MD5 hash.

Button Global $ hCheck

An array is created from the .ini file.
The websites are downloaded.
And get as name the old MD5 hash.

I would like to receive a notification.
As soon as a website changes. I just can not get on there.
:sweating:

How can one call from .ini the web pages stored therein and compare with the old MD5 hach.
And get a notification? Which website has been changed? 

 

#NoTrayIcon
#RequireAdmin

#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <SliderConstants.au3>
#include <GuiconstantsEx.au3>
#include <FileConstants.au3>
#include <InetConstants.au3>
#include <WinAPIFiles.au3>
#include <constants.au3>
#include <String.au3>
#include <Array.au3>
#include <Crypt.au3>

Global $Output
Global $Version = " v0.1"
$sTime = StringFormat("%02i:%02i %02i.%02i.%04i", @HOUR, @MIN, @MDAY, @MON, @YEAR)
Global Const $sIni = @ScriptDir & "\index.ini"
Global $sFilePath = _WinAPI_GetTempFileName(@ScriptDir & "\")
Global $sFilePath2 = @ScriptDir & "\"


Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 3)


HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

MainGUI()

Func MainGUI()
    ; Create tray menu items and set the events
    Global $About = TrayCreateItem("About")
    TrayItemSetOnEvent($About, "_About")
    TrayCreateItem("") ; Create a separator line.
    Global $Exit = TrayCreateItem("Exit")
    TrayItemSetOnEvent($Exit, "_Exit")

    ; Set the action if you left click on the tray icon
    TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "SpecialEvent")
    ; Show the menu if the icon is right clicked
    TraySetClick(8)


    Global $hGUI = GUICreate("Window", 350, 200, -1, -1)
    Global $hInputLink = GUICtrlCreateInput("", 25, 30, 185, 25)
    Global $hButtonPast = GUICtrlCreateButton("In", 220, 30, 25, 25)
    Global $hCheck = GUICtrlCreateButton("check", 160, 60, 50, 25)
    Global $hButtonAddLink = GUICtrlCreateButton("Add", 250, 30, 25, 25)
    GUISetState()

    _Crypt_Startup() ; Startet die Crypt-Bibliothek um die Performance zu optimieren.

    While 1 * Sleep(10)

        ; $msg = GUIGetMsg() ; Aktuelles GUI Event Abfragen
        ;       If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        ;       If $msg = $hClose Then ExitLoop

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

                ; Case $GUI_EVENT_PRIMARYUP
                ;   ToolTip("")

            Case $hButtonPast
                GUICtrlSetData($hInputLink, ClipGet())

            Case $hButtonAddLink

                AddLink()

            Case $hCheck

                CheckLink()

        EndSwitch

    WEnd


    GUIDelete($hGUI) ; Löscht die vorherige GUI und alle Controls.
    _Crypt_Shutdown() ; Beendet die Crypt-Bibliothek.
EndFunc   ;==>MainGUI



Func AddLink()
    Global $sURL = GUICtrlRead($hInputLink)

    InetGetSize($sURL)
    If @error Then
        MsgBox(0, "connect", "unable to connect")
    Else
        MsgBox(0, "connect", "connect")
        ; Ersetzt einige Zeichen.
        ; ocal $sStringLink0 = StringReplace($sURL, ":", "")
        Local $hDownload = InetGet($sURL, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
        ; Wartet bis der Download komplett ist. Dabei wird solange gewartet, bis der zweite Wert von InetGetInfo True zurückgibt.
        Do
            Sleep(250)
        Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
        ; Schließt das durch InetGet zurückgegebene Handle.
        InetClose($hDownload)


        Local $dHash = _Crypt_HashFile($sFilePath, $CALG_MD5)
        ; Local $sWrite = IniWrite($sIni, $sURL, "MD5", $dHash)
        ; Erstellt eine Sektion in der ini mit der Struktur eines Strings.
        Local $sWrite = "MD5=" & $dHash & "=MD5" & @LF & "Date=" & $sTime
        IniWriteSection($sIni, $sURL, $sWrite)

        ;  FileDelete($sFilePath)
        ; MsgBox(0, "", "MD5: " & $dHash)

    EndIf

EndFunc   ;==>AddLink



Func CheckLink()

    Local Const $sFilePath = $sIni

    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf

    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead = FileRead($hFileOpen)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)


    Local $aArray = IniReadSectionNames($sIni)
    _ArrayDelete($aArray, 0)

    Local $aArray_descr = _StringBetween($sFileRead, "MD5=", "=MD5", $STR_ENDISSTART)


    ; Füllt das Array mit Daten.
    For $index = 0 To UBound($aArray, $UBOUND_ROWS) - 1
        $url = $aArray[$index]

        Local $hDownload2 = InetGet($url, $sFilePath2 & $aArray_descr[$index])
        Sleep(250)

    Next

    InetClose($hDownload2)
    _ArrayDisplay($aArray)

EndFunc   ;==>CheckLink


Func SpecialEvent()
    ; Show the GUI
    GUISetState(@SW_SHOW)
    GUISetState(@SW_RESTORE)
    ; Hide the icon
    TraySetState(2)
EndFunc   ;==>SpecialEvent


Func _About()
    MsgBox(0, 0, "Test")
EndFunc   ;==>_About

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

 

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
×
×
  • Create New...