#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $k = 0
$Gui = GUICreate("WM_PAINT", 370, 220, -1, -1, $WS_OVERLAPPEDWINDOW)
GUICtrlCreateLabel('Функция WM_PAINT выполняется, когда окну необходима перерисовка', 5, 5, 360, 70)
$condition = GUICtrlCreateLabel('', 10, 75, 360, 135)

GUISetState()

GUIRegisterMsg($WM_PAINT, "WM_PAINT")

Do
Until GUIGetMsg() = -3

Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)

	$k += 1
	WinSetTitle($Gui, '', 'Вызов ' & $k & ' раз')

	Return $GUI_RUNDEFMSG
EndFunc