To get infos about xbuttons there is a little modification to do
#include <winapi.au3>
#include <WindowsConstants.au3>
HotKeySet('{ESC}', '_Close')
Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo"
Global $hHook
Local $hFunc, $pFunc, $hMod
$hFunc = DllCallbackRegister('_MouseProc', 'long', 'int;wparam;lparam')
$pFunc = DllCallbackGetPtr($hFunc)
$hMod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, $hMod)
While 1
Sleep(20)
WEnd
Func _MouseProc($iCode, $iwParam, $ilParam)
If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
Local $info = DllStructCreate($MSLLHOOKSTRUCT, $ilParam)
Switch $iwParam
Case $WM_XBUTTONDOWN
MsgBox(4096, "", "XButton " & _WinAPI_HiWord(DllStructGetData($info, "mouseData")))
EndSwitch
Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc
Func _Close()
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hHook)
Exit
EndFunc