It would evaluate correctly - but the forum migration screwed a few characters. Anyway, it's a replacement tool to be bound to a shortcut and wouldn't offer dragging the object to a new position, only duplicating it in place.
To answer the orginal question, this will confirm the dialog as soon as it appears:
try destroyDialog ::popupClose catch()
rollout popupClose "Popup Close" width:75
(
checkButton chbAutoClose "AutoClose" checked:true
global closeDetachPopup = fn closeDetachPopup =
(
local hwnd = dialogMonitorOps.getWindowHandle()
if UIAccessor.getWindowText hwnd == "Clone Part of Mesh" then
(
UIAccessor.PressDefaultButton()
true
)
else false
)
fn enableClosing =
(
dialogMonitorOps.enabled = true
dialogMonitorOps.interactive = false
dialogMonitorOps.registerNotification ::closeDetachPopup id:#close_detach_popup
)
fn disableClosing =
(
dialogMonitorOps.unRegisterNotification id:#close_detach_popup
dialogMonitorOps.enabled = false
)
on chbAutoClose changed checked do
if checked then enableClosing() else disableClosing()
on popupClose open do enableClosing()
on popupClose close do disableClosing()
)
createDialog popupClose
Bear in mind, that dialogMonitor prevents user interaction with ANY popup dialog, so if you want to open some settings dialog, material editor etc., uncheck the AutoClose button and check it only while you're detaching.