private void _ScrollMenuItemSubItem(AT reassignDropdown) { try { var left = (int)reassignDropdown.GetElementInfo().RectangleLeft() + 10; var top = (int)reassignDropdown.GetElementInfo().RectangleTop() + 50; switch (_scrollNum) { case 0: HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELDOWN); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELDOWN); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELDOWN); UtilTime.WaitTime(1); _scrollNum = 1; break; case 1: HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELUP); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELUP); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELUP); UtilTime.WaitTime(1); _scrollNum = 0; break; } } catch (Exception e) { throw new Exception("Failed to _ScrollMenuItemSubItem. " + e.Message); } }
private void VerifyAssignedKeyValueAndGridColor(AT keyGridNeedToBeAssigned, AT reassignDialog, string pressedKey, bool blAssignKey) { var gridColorValue = KeyMappingGridColor.Purple; try { var assignedValue = reassignDialog.GetElementFromDescendants(MPObj.AssignedValue, returnNullWhenException: true); DifferentFlowForDifferentPressedKey(pressedKey, () => { gridColorValue = KeyMappingGridColor.Red; if (assignedValue != null && !assignedValue.GetElementInfo().IsOffscreen()) { _r.RecordActionFailedDuringCaseRunning($"The Key is not disabled, the reassignable textbox is still there.", "ReassignTextboxStillThere"); } }, () => { gridColorValue = KeyMappingGridColor.Green; var reassignTitleValue = reassignDialog.GetElementFromDescendants(MPObj.ReassignTitleValue); if (assignedValue.GetElementInfo().FullDescription() != reassignTitleValue.GetElementInfo().FullDescription()) { _r.RecordActionFailedDuringCaseRunning($"The assigned key is not restored to {reassignTitleValue.GetElementInfo().FullDescription()} when enabling it.", "assignedValueNotRestored"); } }, () => { gridColorValue = KeyMappingGridColor.Purple; var value = assignedValue.GetElementInfo().FullDescription(); if (!value.Equals(pressedKey)) { _r.RecordActionFailedDuringCaseRunning($"Input {pressedKey}, but got {value}.", "assignedValueWrong"); } if (keyGridNeedToBeAssigned.GetElementInfo().Name().Equals(pressedKey)) { gridColorValue = KeyMappingGridColor.Green; } }); } catch (Exception e) { throw new Exception(e.Message); } finally { var saveOrCloseButton = reassignDialog.GetElementFromDescendants(blAssignKey ? MPObj.ReassignSaveButton : MPObj.ReassignCloseButton); saveOrCloseButton.DoClickPoint(0.4); } if (!keyGridNeedToBeAssigned.GetElementInfo().FullDescription().Equals(gridColorValue)) { _r.RecordActionFailedDuringCaseRunning($"Key {pressedKey} in not in {KeyMappingGridColor.GetVarName(gridColorValue)} color.", "WrongColor"); } }
private Boolean existElement(string targetPropertyType, string targetPropertyValue, string targetControlType) { AT _Element = base.GetInvokerElement(targetPropertyType, targetPropertyValue, targetControlType); if (_Element.GetElementInfo().Exists()) { return(true); } throw new Exception(string.Format("Not exist.")); }
private AT LaunchAndGetWmplayer() { UtilProcess.KillAllProcessesByName("wmplayer"); UtilTime.WaitTime(1); var p = UtilWmp.StartWmpWithMedias(Path.Combine(this.MediaFolderPath, "1.mp3"), Path.Combine(this.MediaFolderPath, "2.mp3"), Path.Combine(this.MediaFolderPath, "3.mp3")); var wmpWindow = new AT().GetElementFromHwndAndWaitAppears(p); HWSimulator.HWSend.MoveMouseTo((int)(wmpWindow.GetElementInfo().RectangleRight() - wmpWindow.GetElementInfo().RectangleLeft()) / 2, (int)(wmpWindow.GetElementInfo().RectangleBottom() - wmpWindow.GetElementInfo().RectangleTop()) / 2); return(wmpWindow); }
private void VerifyKeyWork(AT keyGridNeedToBeAssigned, string pressedKey) { var key = Hw.KbKeys.GetScKeyByUiaName(keyGridNeedToBeAssigned.GetElementInfo().Name()); DifferentFlowForDifferentPressedKey(pressedKey, () => { TestIt.SendUsbKeyAndCheck(key, null); }, () => { TestIt.SendUsbKeyAndCheck(key, key.KeyCode); }, () => { var f = typeof(MasterPlus.ReassignMenuItems.MediaKeysItems).GetFields().FirstOrDefault(x => x.GetValue("").Equals(pressedKey)); if (f != null) { var key1 = Hw.KbKeys.GetScKeyByVarName(f.Name); TestIt.SendUsbKeyAndCheck(key, key1.KeyCode); } else { TestIt.SendUsbKeyAndCheck(key, Hw.KbKeys.GetScKeyByUiaName(pressedKey).KeyCode); } }); }