#include <GUIConstantsEx.au3>
#include <EventLog.au3>
#include <WinAPI.au3>

Global $iMemo

_Main()

Func _Main()
	Local $hEventLog, $hGUI, $hEvent, $iResult

	; Создаёт GUI
	$hGUI = GUICreate("EventLog", 400, 300)
	$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
	GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
	GUISetState()

	; Set up event
	$hEventLog = _EventLog__Open ("", "Security")
	$hEvent = _WinAPI_CreateEvent (0, False, False, "")
	_EventLog__Notify ($hEventLog, $hEvent)

	; Wait for new event to occur
	MemoWrite("Waiting for new event")
	$iResult = _WinAPI_WaitForSingleObject ($hEvent)
	_WinAPI_CloseHandle ($hEvent)
	_EventLog__Close ($hEventLog)

	; Write results
	If $iResult = -1 Then
		MemoWrite("Wait failed")
	Else
		MemoWrite("New event occurred")
	EndIf

	; Цикл выполняется, пока окно не будет закрыто
	Do
	Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; Записывает строку в элемент для заметок
Func MemoWrite($sMessage)
	GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite