In a Windows GUI like an AutoIt GUI, functionality and user actions are largely controlled through Windows messages. Therefore, it's interesting to monitor Windows messages. That's the purpose of this example.
How does it work?
This is a simple example (Examples\1) Native controls\GUICtrlCreateButton.au3):
#include <GUIConstantsEx.au3>
#include "..\..\Includes\WinMsgMon_Button.au3" ; <<<<<<<<<<<<<<<<<<<