Sha256: a1b500b3e0cf6a741c2dc1a3e43567aeab31aa9490d59e2872713ea13c0fc5a8

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

using System;
using System.Runtime.InteropServices;
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.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

9 entries across 9 versions & 1 rubygems

Version Path
uia-0.0.7.3 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.7.2 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.7.1 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.7 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.6.1 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.6 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.5.1 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.5 ext/UiaDll/UIA.Helper/Clicker.cs
uia-0.0.4 ext/UiaDll/UIA.Helper/Clicker.cs