#Include <WinAPIEx.au3>
#Include <MsgBoxConstants.au3>
$hMsgBox = _MsgBox_Create(BitOR($MB_ICONQUESTION, $MB_YESNOCANCEL), 'Title', 'Text', 3)
Do
$iCode = _MsgBox_GetCode($hMsgBox)
Until $iCode <> 259 ;STILL_ACTIVE
Switch $iCode
Case $IDCANCEL
MsgBox(64, '', 'You presed Cancel button.')
Case $IDYES
MsgBox(64, '', 'You presed Yes button.')
Case $IDNO
MsgBox(64, '', 'You presed No button.')
Case $IDTIMEOUT, 4294967295
MsgBox(64, '', 'MsgBox timed out.')
EndSwitch
_MsgBox_Close($hMsgBox)
Func _MsgBox_Create($iFlags, $sTitle, $sText, $iTimeout = 0, $hWnd = 0)
Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine "Exit MsgBox(' & $iFlags & ', ''' & $sTitle & ''', ''' & $sText & ''', ' & $iTimeout & ', ' & $hWnd & ')"')
Return _WinAPI_OpenProcess(0x0400, 0, $iPID)
EndFunc
Func _MsgBox_Close($hMsgBox)
Return _WinAPI_CloseHandle($hMsgBox)
EndFunc
Func _MsgBox_GetCode($hMsgBox)
Return _WinAPI_GetExitCodeProcess($hMsgBox)
EndFunc