Use the Global.DoWaitFor(object_id, nnn);

-- This function may be used to wait for some object or to find an object. See Global.DoWaitFor.

So if you have some object (such as text label, button and so on) available for the current dialog you may 'wait' for it for small amount of time. If it is not found the the dialog does not exist. For example:

if(Global.DoWaitFor('Confirm_Label',1000)){ ...}

Second: Use the internal API available through g_util object:

var found = g_util.FindWindows('Error Message', 'regex:.*'); if(found.length==1) { // Actions if the window is found }