public static IUiElement PerformCoordinatedClick(this IControlInputHolder holder, int X, int Y) { var cmdlet = new HasControlInputCmdletBase(); cmdlet.ClickControl( cmdlet, holder.GetParentElement(), new ClickSettings() { RelativeX = X, RelativeY = Y }); return(holder.GetParentElement()); }
// // internal static IControlInputHolder GetC(this IControlInputHolder holder) // internal static string GetC(this IControlInputHolder holder) // { // return "c"; // holder; // } public static IUiElement PerformClick(this IControlInputHolder holder) { var cmdlet = new HasControlInputCmdletBase(); cmdlet.ClickControl( cmdlet, holder.GetParentElement(), new ClickSettings() { RelativeX = Preferences.ClickOnControlByCoordX, RelativeY = Preferences.ClickOnControlByCoordY }); return(holder.GetParentElement()); }
internal static IUiElement InvokeContextMenu(this IUiElement inputObject, HasControlInputCmdletBase cmdlet, int x, int y) { IUiElement resultElement = null; try { if (!cmdlet.ClickControl( cmdlet, inputObject, new ClickSettings() { RightClick = true, RelativeX = (x < 0 ? Preferences.ClickOnControlByCoordX : x), RelativeY = (y < 0 ? Preferences.ClickOnControlByCoordY : y) })) { } } catch (Exception) { throw new Exception("failed to click on the control"); } // 20140116 // what are these x and y? // int x = Cursor.Position.X; // int y = Cursor.Position.Y; var contextMenuSearcher = AutomationFactory.GetSearcherImpl <ContextMenuSearcher>(); var contextMenuSearcherData = new ContextMenuSearcherData { InputObject = inputObject, ProcessId = inputObject.GetCurrent().ProcessId }; var elementsMenuRoot = contextMenuSearcher.GetElements( contextMenuSearcherData, Preferences.Timeout); resultElement = elementsMenuRoot.First(element => null != element); return(resultElement); }