/// <summary> /// UIElement validation check /// </summary> /// <param name="hash">UIElement hash to check</param> /// <param name="isEnabled">should be enabled</param> /// <param name="isVisible">should be visible</param> /// <param name="bisValid">should be a valid UIElement</param> /// <returns>true if all requirements are valid</returns> public static bool isValid(ulong hash, bool isEnabled = true, bool isVisible = true, bool bisValid = true) { try { if (!UIElement.IsValidElement(hash)) { return(false); } else { var element = UIElement.FromHash(hash); if ((isEnabled && !element.IsEnabled) || (!isEnabled && element.IsEnabled)) { return(false); } if ((isVisible && !element.IsVisible) || (!isVisible && element.IsVisible)) { return(false); } if ((bisValid && !element.IsValid) || (!bisValid && element.IsValid)) { return(false); } } } catch { return(false); } return(true); }
private void ErrorHandling() { if (ErrorDialog.IsVisible) { // Check if Demonbuddy found errordialog if (!handlederror) { Send("CheckConnection", pause: true); handlederror = true; } else { handlederror = false; ErrorDialog.Click(); bootTo(); } } else if (UIElementTester.isValid(_UIElement.errordialog_okbutton)) { // Demonbuddy failed to find error dialog use static hash to find the OK button Send("CheckConnection", pause: true); UIElement.FromHash(_UIElement.errordialog_okbutton).Click(); bootTo(); } else { handlederror = false; if (UIElementTester.isValid(_UIElement.loginscreen_username)) { // We are at loginscreen Send("CheckConnection", pause: true); } } }