Sha256: ec3bcc527d0e4ba645df09df3113d677e225d9f8d17dd6feea42e7288b48d326
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
using System; using System.Runtime.InteropServices; using System.Windows.Automation; using System.Windows.Forms; using RAutomation.UIA.Extensions; namespace RAutomation.UIA.Controls { public class Clicker { [DllImport("user32.dll")] static extern void mouse_event(uint flags, uint x, uint y, uint data, int extraInfo); [Flags] public enum MouseEvent { Leftdown = 0x00000002, Leftup = 0x00000004, } private const uint MOUSEEVENTLF_LEFTDOWN = 0x2; private const uint MOUSEEVENTLF_LEFTUP = 0x4; public static bool Click(AutomationElement element) { try { if (AutomationElement.IsInvokePatternAvailableProperty.In(element)) { element.As<InvokePattern>(InvokePattern.Pattern).Invoke(); } else if (AutomationElement.IsTogglePatternAvailableProperty.In(element)) { element.AsTogglePattern().Toggle(); } else if (AutomationElement.IsSelectionItemPatternAvailableProperty.In(element)) { element.AsSelectionItem().Select(); } return true; } catch (Exception e) { Console.WriteLine(e); return false; } } public static void MouseClick(AutomationElement element) { 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); } } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rautomation-0.12.0 | ext/UiaDll/RAutomation.UIA/Controls/Clicker.cs |
rautomation-0.11.0 | ext/UiaDll/RAutomation.UIA/Controls/Clicker.cs |