mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
22 lines
857 B
C#
22 lines
857 B
C#
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using mRemoteNG.App;
|
|
|
|
namespace mRemoteNG.Tools
|
|
{
|
|
public class MouseClickSimulator
|
|
{
|
|
public static void Click(Control controlToClick, Point currentMousePosition)
|
|
{
|
|
// Simulate a mouse event since one wasn't generated by Windows
|
|
var clientMousePosition = controlToClick.PointToClient(currentMousePosition);
|
|
var tempWLow = clientMousePosition.X;
|
|
var tempWHigh = clientMousePosition.Y;
|
|
NativeMethods.SendMessage(controlToClick.Handle, NativeMethods.WM_LBUTTONDOWN, (IntPtr)NativeMethods.MK_LBUTTON, (IntPtr)NativeMethods.MAKELPARAM(ref tempWLow, ref tempWHigh));
|
|
clientMousePosition.X = tempWLow;
|
|
clientMousePosition.Y = tempWHigh;
|
|
controlToClick.Focus();
|
|
}
|
|
}
|
|
} |