public override EnumActionResult Execute() { ControlUltraTree utree = _vm.GetUltraTree(); if (null == utree) { _vm.host.WriteLog("No ultra tree object."); return(EnumActionResult.ERROR); } string key = _vm.variables.Get(m_params[1]); if (false == utree.Children.ContainsKey(key)) { _vm.host.WriteLog("Ultra Tree Children doesn't contain key: '" + key + "'"); return(EnumActionResult.ERROR); } AutomationElement treeItem = utree.Children[key]; _vm.host.UpdateMarker(treeItem.Current.BoundingRectangle); UtilAutomation.ClickOn(treeItem.Current.BoundingRectangle, false); return(EnumActionResult.OK); }
private void CollapseAll(AutomationElement tree) { ControlUltraTree utree = _vm.GetUltraTree(); if (null == utree) { string msg = "'CollapseAll' command is used in pair with 'ExpandAll'."; _vm.host.WriteLog(msg); return; } List <AutomationElement> list = new List <AutomationElement>(); foreach (KeyValuePair <string, AutomationElement> item in utree.Roots) { list.Add(item.Value); } for (int i = list.Count - 1; i > -1; --i) { _vm.host.UpdateMarker(list[i].Current.BoundingRectangle); UtilAutomation.ClickOn(list[i].Current.BoundingRectangle, true); UtilSys.Wait(40); } _vm.RemoveControl(tree.Current.Name); }
public override EnumActionResult Execute() { try { string key = string.Empty; int indexToFind = int.Parse(_vm.variables.Get(m_params[1])); ControlGrid grd = _vm.GetGrid(); _vm.host.aeCurrent = grd.aeRows[indexToFind]; _vm.host.UpdateMarker(_vm.host.aeCurrent.Current.BoundingRectangle); AutomationPattern.ScrollIntoView(_vm.host.aeCurrent); _vm.host.aeCurrent.SetFocus(); AutomationElement row = grd.aeRows[indexToFind]; AutomationElementCollection cells = row.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text)); key = _vm.variables.Get(m_params[3]); Dictionary <string, string> dic = grd.Rows[indexToFind]; int j = 0; foreach (string k in dic.Keys) { if (k == key) { UtilAutomation.ClickOn(cells[j].Current.BoundingRectangle, true); UtilSys.Wait(500); string value = _vm.variables.Get(m_params[5]); value += "+{ENTER}"; System.Windows.Forms.SendKeys.SendWait(value); return(EnumActionResult.OK); } ++j; } return(EnumActionResult.ERROR); } catch (Exception) { throw; } }
private void ExpandAll(AutomationElement tree) { PropertyCondition typeTreeItem = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TreeItem); AutomationElementCollection col = tree.FindAll(TreeScope.Descendants, typeTreeItem); if (0 == col.Count) { _vm.host.WriteLog("No elements nothing to expand"); return; } double LeftParent = col[0].Current.BoundingRectangle.Left; bool hasChildren = false; for (int i = col.Count - 1; i > -1; --i) { AutomationElement cur = col[i]; _vm.host.UpdateMarker(cur.Current.BoundingRectangle); UtilSys.Wait(50); double LeftCurrent = cur.Current.BoundingRectangle.Left; if (LeftCurrent == LeftParent) // root element { if (!hasChildren) { UtilAutomation.ClickOn(cur.Current.BoundingRectangle, true); UtilSys.Wait(100); } hasChildren = false; } else // child element { hasChildren = true; } } }
public override EnumActionResult Execute() { string posX = string.Empty; string posY = string.Empty; System.Windows.Point pos = new System.Windows.Point(); string type = m_params[0]; switch (type) { case "mouse.SetDragSource": _aeDrag = _vm.host.aeCurrent; break; case "mouse.SetDropSource": _aeDrop = _vm.host.aeCurrent; break; case "mouse.DoDragAndDrop": UtilAutomation.MouseHover(_aeDrag); UtilSys.Wait(1000); UtilAutomation.MouseLeftDown(); UtilSys.Wait(1000); UtilAutomation.MouseHover(_aeDrop); UtilSys.Wait(1000); UtilAutomation.MouseLeftUp(); break; case "mouse.RightClickOn": if (_vm.host.IsRegion) { _vm.host.LeftClickPos = UtilAutomation.RightClickOn(_vm.host.ImageRegion); } else { _vm.host.LeftClickPos = UtilAutomation.RightClickOn(_vm.host.aeCurrent.Current.BoundingRectangle); } break; case "mouse.RightClickClient": { posX = _vm.variables.Get(m_params[1]); posY = _vm.variables.Get(m_params[3]); pos.X = Convert.ToDouble(posX); pos.Y = Convert.ToDouble(posY); UtilAutomation.ClientRightClick(_vm.host.TargetWindow, pos, false); } break; case "mouse.RightClickScreen": { posX = _vm.variables.Get(m_params[1]); posY = _vm.variables.Get(m_params[3]); pos.X = Convert.ToDouble(posX); pos.Y = Convert.ToDouble(posY); UtilAutomation.ScreenRightClick(pos, false); } break; case "mouse.ClickOn": if (_vm.host.IsRegion) { if (!UtilAutomation.ClickOn(_vm.host.ImageRegion, false)) { return(EnumActionResult.ERROR); } } else { if (!UtilAutomation.ClickOn(_vm.host.aeCurrent.Current.BoundingRectangle, false)) { return(EnumActionResult.ERROR); } } break; case "mouse.ClickClient": { posX = _vm.variables.Get(m_params[1]); posY = _vm.variables.Get(m_params[3]); pos.X = Convert.ToDouble(posX); pos.Y = Convert.ToDouble(posY); UtilAutomation.ClientClick(_vm.host.TargetWindow, pos, false); } break; case "mouse.ClickScreen": { posX = _vm.variables.Get(m_params[1]); posY = _vm.variables.Get(m_params[3]); pos.X = Convert.ToDouble(posX); pos.Y = Convert.ToDouble(posY); UtilAutomation.ScreenClick(pos, false); } break; case "mouse.DoubleClickOn": if (_vm.host.IsRegion) { if (!UtilAutomation.ClickOn(_vm.host.ImageRegion, true)) { return(EnumActionResult.ERROR); } } else { if (!UtilAutomation.ClickOn(_vm.host.aeCurrent.Current.BoundingRectangle, true)) { return(EnumActionResult.ERROR); } } break; case "mouse.DoubleClickClient": { posX = _vm.variables.Get(m_params[1]); posY = _vm.variables.Get(m_params[3]); pos.X = Convert.ToDouble(posX); pos.Y = Convert.ToDouble(posY); UtilAutomation.ClientClick(_vm.host.TargetWindow, pos, true); } break; case "mouse.DoubleClickScreen": { posX = _vm.variables.Get(m_params[1]); posY = _vm.variables.Get(m_params[3]); pos.X = Convert.ToDouble(posX); pos.Y = Convert.ToDouble(posY); UtilAutomation.ScreenClick(pos, true); } break; default: _vm.host.WriteLog("Actionmouse->Unrecognized command [" + type + "]."); return(EnumActionResult.ERROR); } return(EnumActionResult.OK); }