#pragma warning restore 649 // Mephobia HF reported that this function fails to send mouse clicks to hidden windows public static void ClickOnPoint(IntPtr wndHandle, Win32.Point clientPoint) { //var oldPos = Cursor.Position; // ref to System.Windows.Forms /// get screen coordinates ClientToScreen(wndHandle, ref clientPoint); /// set cursor on coords, and press mouse //Cursor.Position = new Point(clientPoint.x, clientPoint.y); // ref to System.Windows.Forms var inputMouseDown = new INPUT(); inputMouseDown.Type = 0; /// input type mouse inputMouseDown.Data.Mouse.Flags = 0x0002; /// left button down var inputMouseUp = new INPUT(); inputMouseUp.Type = 0; /// input type mouse inputMouseUp.Data.Mouse.Flags = 0x0004; /// left button up var inputs = new INPUT[] { inputMouseDown, inputMouseUp }; SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(INPUT))); /// return mouse //Cursor.Position = oldPos; // ref to System.Windows.Forms }
public static bool Click(Win32.Point point) { if (bshandle == IntPtr.Zero) { bshandle = GetBlueStackWindowHandle(); } if (bshandle == IntPtr.Zero) { return(false); } MouseHelper.ClickOnPoint(bshandle, point); return(true); }
private bool OffsetToBSClientScrrenCoord(ref Rectangle rect) { if (!BlueStackHelper.IsBlueStackRunning) { return(false); } Win32.Point origin = new Win32.Point(0, 0); if (Win32.ClientToScreen(BlueStackHelper.GetBlueStackWindowHandle(), ref origin)) { return(false); } rect.Offset(origin.x, origin.y); return(true); }
public static extern bool ClientToScreen(IntPtr hWnd, ref Win32.Point lpPoint);
private bool OffsetToBSClientScrrenCoord(ref Rectangle rect) { if (!BlueStackHelper.IsBlueStackRunning) return false; Win32.Point origin = new Win32.Point(0, 0); if (Win32.ClientToScreen(BlueStackHelper.GetBlueStackWindowHandle(), ref origin)) return false; rect.Offset(origin.x, origin.y); return true; }