本文整理汇总了C#中System.Windows.Automation.AutomationElement.GetClickablePoint方法的典型用法代码示例。如果您正苦于以下问题:C# AutomationElement.GetClickablePoint方法的具体用法?C# AutomationElement.GetClickablePoint怎么用?C# AutomationElement.GetClickablePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Automation.AutomationElement
的用法示例。
在下文中一共展示了AutomationElement.GetClickablePoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MouseClick
public static void MouseClick(AutomationElement element)
{
element.ScrollToIfPossible();
element.SetFocus();
var clickablePoint = element.GetClickablePoint();
Cursor.Position = new System.Drawing.Point((int)clickablePoint.X, (int)clickablePoint.Y);
mouse_event(MOUSEEVENTLF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTLF_LEFTUP, 0, 0, 0, 0);
}
示例2: DragDropFileTo
internal void DragDropFileTo(FileInfo file, AutomationElement el)
{
Start(file.DirectoryName);
ListUiItem fileInExplorer;
fileInExplorer = GetFile(file.Name);
Mouse.MoveTo(fileInExplorer.ClickablePoint);
Mouse.Down(MouseButton.Left);
Minimize();
Mouse.MoveTo(el.GetClickablePoint().Convert());
Mouse.Up(MouseButton.Left);
}
示例3: Center
private static Point Center(AutomationElement element)
{
try
{
return element.GetClickablePoint();
}
catch (Exception)
{
return element.Current.BoundingRectangle.Center();
}
}
示例4: ClickControl
private static void ClickControl(AutomationElement control)
{
try
{
AutoItX3Lib.AutoItX3 at = new AutoItX3Lib.AutoItX3();
System.Windows.Point clickpoint1 = control.GetClickablePoint();
Console.WriteLine("Got clickable Points ");
double x = clickpoint1.X;
double y = clickpoint1.Y;
int x1 = Convert.ToInt32(x);
int y1 = Convert.ToInt32(y);
at.MouseMove(x1, y1, -1);
try
{
at.MouseClick("LEFT", x1, y1, 1);
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
catch (Exception ex)
{
throw new Exception("error on getclickablepoints :" + ex.Message);
}
}
示例5: AutomationElementGetClickablePoint
public static void AutomationElementGetClickablePoint(AutomationElement element)
{
Dump("GetClickablePoint()", true, element);
try
{
Point obj = element.GetClickablePoint();
}
catch (Exception exception)
{
VerifyException(element, exception,
typeof(ElementNotAvailableException),
typeof(NoClickablePointException)
);
}
}
示例6: MoveToAndClick
/// <summary>
/// Move the mouse to an element and click on it. The primary mouse button will be used
/// this is usually the left button except if the mouse buttons are swaped.
/// </summary>
/// <param name="el">The element to click on</param>
/// <exception cref="NoClickablePointException">If there is not clickable point for the element</exception>
///
/// <outside_see conditional="false">
/// This API does not work inside the secure execution environment.
/// <exception cref="System.Security.Permissions.SecurityPermission"/>
/// </outside_see>
public static void MoveToAndClick( AutomationElement el )
{
if (el == null)
{
throw new ArgumentNullException("el");
}
MoveToAndClick(el.GetClickablePoint());
}
示例7: DoubleClick
private static void DoubleClick(AutomationElement element)
{
Point p = element.GetClickablePoint();
MoveToAndDoubleClick(p);
}
示例8: Click
private static void Click(AutomationElement element)
{
try
{
Point p = element.GetClickablePoint();
MoveToAndClick(p);
}
catch (Exception ex)
{
}
}
示例9: DragDropMultipleFilesTo
internal void DragDropMultipleFilesTo(string[] files, string folder, AutomationElement el)
{
var dir = FileLocator.LocateFolder(folder);
Start(dir.FullName);
ClickFile(files[0]);
Keyboard.Press(Key.Ctrl);
for (int i = 1; i < files.Count() - 1; i++) {
ClickFile(files[i]);
}
var fileInExplorer = GetFile(files.Last());
Mouse.MoveTo(fileInExplorer.ClickablePoint);
Mouse.Down(MouseButton.Left);
Keyboard.Release(Key.Ctrl);
Minimize();
Mouse.MoveTo(el.GetClickablePoint().Convert());
Mouse.Up(MouseButton.Left);
}
示例10: DragAndDrop
/// <summary>
/// Moves or copies (taking the default behavior) one or more items in solution explorer to
/// the destination using the mouse.
/// </summary>
private static void DragAndDrop(AutomationElement destination, params AutomationElement[] source) {
SelectItemsForDragAndDrop(source);
try {
Mouse.MoveTo(destination.GetClickablePoint());
} finally {
Mouse.Up(MouseButton.Left);
}
}
示例11: ClickablePoint
/// <summary>
/// Click Automation Element object
/// </summary>
/// <param name="automationElement">Automation Element object</param>
/// <param name="leftOrRight">mouse button option :left / right</param>
/// <returns>successed 1, unsuccesse 0</returns>
public int ClickablePoint(AutomationElement automationElement, string leftOrRight)
{
try
{
System.Windows.Point ClickablePoint = automationElement.GetClickablePoint();
this.MouseClick((int)ClickablePoint.X, (int)ClickablePoint.Y, leftOrRight);
return 1;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return 0;
}
}
示例12: RightClickControl
private void RightClickControl(AutomationElement control)
{
try
{
logTofile(_eLogPtah, "Inside Right click method");
System.Windows.Point clickpoint1 = control.GetClickablePoint();
double x = clickpoint1.X;
double y = clickpoint1.Y;
int x1 = Convert.ToInt32(x);
int y1 = Convert.ToInt32(y);
logTofile(_eLogPtah, "Clickable points " + x1 + " " + y1);
at.MouseClick("RIGHT", x1, y1, 1);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例13: ClickControl
private void ClickControl(AutomationElement control)
{
logTofile(_eLogPtah, "ClickControl: outside of try");
try
{
logTofile(_eLogPtah, "Inside Left click method control type is : " + control.Current.LocalizedControlType);
System.Windows.Point clickpoint1 = control.GetClickablePoint();
logTofile(_eLogPtah, "Got clickable Points ");
double x = clickpoint1.X;
double y = clickpoint1.Y;
int x1 = Convert.ToInt32(x);
int y1 = Convert.ToInt32(y);
logTofile(_eLogPtah, "clickable Points " + x1.ToString() + " " + y1.ToString());
at.MouseMove(x1, y1, -1);
try
{
at.MouseClick("LEFT", x1, y1, 1);
}
catch (Exception e)
{
logTofile(_eLogPtah, "error on mouseclick :" + e.Message);
}
}
catch (Exception ex)
{
logTofile(_eLogPtah, "Erroring Line numner in ClickControl " + GetStacktrace(ex).ToString());
throw new Exception("error on getclickablepoints :" + ex.Message);
}
}
示例14: MouseInvokeFromClickablePoint
public static void MouseInvokeFromClickablePoint(AutomationElement elem)
{
var clickablePoint = elem.GetClickablePoint();
Mouse.MoveTo(new System.Drawing.Point((int)clickablePoint.X, (int)clickablePoint.Y));
if ( ! elem.Current.IsEnabled)
{
throw new InvalidOperationException("Element '" + GetIdOrName(elem) + "' cannot be clicked since IsEnabled=false");
}
Mouse.Click(MouseButton.Left);
}
示例15: DragDropFileTo
internal void DragDropFileTo(FileInfo file, AutomationElement el)
{
Start(file.DirectoryName);
Maximize();
WaitWhileBusy();
ListBox("Items View").TrySetFocus();
List<ListUiItem> files = GetAllFiles();
ListUiItem fileInExplorer = GetFile(files, file.Name);
fileInExplorer.SetFocus();
Mouse.MoveTo(fileInExplorer.ClickablePoint);
Mouse.Down(MouseButton.Left);
Thread.Sleep(500);
Mouse.MoveTo(new Point(100, 100)); //ensure start of mouse drag
Thread.Sleep(500);
Mouse.MoveTo(new Point(750, 500)); //trying to always move the cursor to an approximated center on a 1080p display, which is still within a 1366x768 display
Thread.Sleep(500);
Minimize();
var centerElement = el.GetClickablePoint().Convert();
Log.DebugFormat("Point to drag to x/y: {0}, {1}", centerElement.X, centerElement.Y);
if (!(centerElement.X < 10 && centerElement.Y < 10)) //failsafe, for our tests it's better to keep the position of 750,500 than end up with 0,0
Mouse.MoveTo(centerElement);
Mouse.Up(MouseButton.Left);
}