def __init__(self, dialogHwnd): self.Window = ui_automation_util.WindowInfo(dialogHwnd) self.Win32Buttons = [] self.Buttons = [] for win32Button in win32_user32.FindWindows(dialogHwnd, BUTTON_CLASS_NAME, None): buttonInfo = ui_automation_util.WindowInfo(win32Button) self.Win32Buttons.append(buttonInfo) for directUI in win32_user32.FindWindows(dialogHwnd, DIRECTUI_CLASS_NAME, None): for ctrlNotifySink in win32_user32.FindWindows( directUI, CTRLNOTIFYSINK_CLASS_NAME, None): for button in win32_user32.FindWindows(ctrlNotifySink, BUTTON_CLASS_NAME, None): buttonInfo = ui_automation_util.WindowInfo(button) self.Buttons.append(buttonInfo) return
def DismissCheekyRevitDialogBoxes(revitProcessId, output_): output = global_test_mode.PrefixedOutputForGlobalTestMode( output_, REVIT_DIALOG_MESSAGE_HANDLER_PREFIX) enabledDialogs = ui_automation_util.GetEnabledDialogsInfo(revitProcessId) if len(enabledDialogs) > 0: for enabledDialog in enabledDialogs: revitDialog = RevitDialogInfo(enabledDialog.Hwnd) buttons = revitDialog.Buttons win32Buttons = revitDialog.Win32Buttons if enabledDialog.WindowText == MODEL_UPGRADE_WINDOW_TITLE and len( buttons) == 0: pass # Do nothing for model upgrade dialog box. It has no buttons and will go away on its own. elif (enabledDialog.WindowText == LOAD_LINK_WINDOW_TITLE and len(win32Buttons) == 1 and ui_automation_util.GetButtonText( win32Buttons[0]) == CANCEL_LINK_BUTTON_TEXT): pass # Do nothing for this dialog box. It will go away on its own. elif enabledDialog.WindowText == script_host_error.BATCH_RVT_ERROR_WINDOW_TITLE: # Report dialog detection but do nothing for BatchRvt error message windows. if not HAVE_REPORTED_BATCH_RVT_ERROR_WINDOW_DETECTION[0]: output() output( "WARNING: Revit Batch Processor error window detected! Processing has halted!" ) HAVE_REPORTED_BATCH_RVT_ERROR_WINDOW_DETECTION[0] = True staticControls = list( ui_automation_util.WindowInfo(hwnd) for hwnd in win32_user32.FindWindows( enabledDialog.Hwnd, STATIC_CONTROL_CLASS_NAME, None)) if len(staticControls) > 0: output() output("Dialog has the following static control text:") for staticControl in staticControls: staticControlText = staticControl.WindowText if not str.IsNullOrWhiteSpace(staticControlText): output() output(staticControlText) elif enabledDialog.WindowText == CHANGES_NOT_SAVED_TITLE and len( buttons) == 4: output() output("'" + enabledDialog.WindowText + "' dialog box detected.") DismissRevitDialogBox(enabledDialog.WindowText, buttons, DO_NOT_SAVE_THE_PROJECT_TEXT, output) elif enabledDialog.WindowText == CLOSE_PROJECT_WITHOUT_SAVING_TITLE and len( buttons) == 3: output() output("'" + enabledDialog.WindowText + "' dialog box detected.") DismissRevitDialogBox( enabledDialog.WindowText, buttons, RELINQUISH_ALL_ELEMENTS_AND_WORKSETS_TEXT, output) elif enabledDialog.WindowText == SAVE_FILE_WINDOW_TITLE and len( buttons) == 3: output() output("'" + enabledDialog.WindowText + "' dialog box detected.") DismissRevitDialogBox(enabledDialog.WindowText, buttons, NO_BUTTON_TEXT, output) elif enabledDialog.WindowText == EDITABLE_ELEMENTS_TITLE and len( buttons) == 3: output() output("'" + enabledDialog.WindowText + "' dialog box detected.") DismissRevitDialogBox(enabledDialog.WindowText, buttons, RELINQUISH_ELEMENTS_AND_WORKSETS_TEXT, output) elif enabledDialog.WindowText in [ "Revit", str.Empty ] and len(buttons) == 0 and len(win32Buttons) > 0: output() output("'" + enabledDialog.WindowText + "' dialog box detected.") staticControls = list( ui_automation_util.WindowInfo(hwnd) for hwnd in win32_user32.FindWindows( enabledDialog.Hwnd, STATIC_CONTROL_CLASS_NAME, None)) if len(staticControls) > 0: output() output("Dialog has the following static control text:") for staticControl in staticControls: staticControlText = staticControl.WindowText if not str.IsNullOrWhiteSpace(staticControlText): output() output(staticControlText) SendButtonClick(win32Buttons, output) elif enabledDialog.WindowText == AUTODESK_CUSTOMER_INVOLVEMENT_PROGRAM_TITLE and len( buttons) == 0 and len(win32Buttons) > 0: output() output("'" + enabledDialog.WindowText + "' dialog box detected.") output() output("Sending close message...") win32_user32.SendCloseMessage(enabledDialog.Hwnd) output() output("...sent.") elif enabledDialog.WindowText in OPENING_WORKSETS_TITLES and len( buttons) == 0 and len(win32Buttons) > 0: output() output("'" + enabledDialog.WindowText + "' dialog box detected.") output() SendButtonClick(win32Buttons, output) else: output() output("Revit dialog box detected!") output() output("\tDialog box title: '" + enabledDialog.WindowText + "'") buttons = buttons if len(buttons) > 0 else win32Buttons for button in buttons: buttonText = ui_automation_util.GetButtonText(button) output() output("\tButton: '" + buttonText + "'") SendButtonClick(buttons, output) return