Sha256: ffd2135c0cb954797339148f6fd8dffad80955cfc27a011df2a472c2088d3951
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
using System; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Automation; using System.Windows.Forms; namespace UIA.Helper { 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 void MouseClick(AutomationElement element) { element.ScrollToIfPossible(); element.TryToFocus(); var clickablePoint = ClickablePoint(element); 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); } private static Point ClickablePoint(AutomationElement element) { try { return element.GetClickablePoint(); } catch (Exception) { return element.Current.BoundingRectangle.Center(); } } } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uia-0.0.9 | ext/UiaDll/UIA.Helper/Clicker.cs |