private void SameImageMouseDragTriggerProcess(IntPtr hWnd, Point start, Point arrive, IBaseEventTriggerModel model, Tuple <float, float> factor, ProcessConfigModel config) { LogHelper.Debug($">>>>Same Drag Mouse Start Target X : { arrive.X } Target Y : { arrive.Y }"); var interval = 3; var middlePoints = this.GetIntevalDragMiddlePoint(start, arrive, interval); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonDown, 1, start.ToLParam()); Task.Delay(10).Wait(); Point mousePosition; for (int i = 0; i < middlePoints.Count; ++i) { mousePosition = new Point() { X = Math.Abs(model.ProcessInfo.Position.Left + middlePoints[i].X * -1) * factor.Item1, Y = Math.Abs(model.ProcessInfo.Position.Top + middlePoints[i].Y * -1) * factor.Item2 }; LogHelper.Debug($">>>>Same Drag Move Mouse Target X : { mousePosition.X } Target Y : { mousePosition.Y }"); NativeHelper.PostMessage(hWnd, WindowMessage.MouseMove, 1, mousePosition.ToLParam()); Task.Delay(config.DragDelay).Wait(); } mousePosition = new Point() { X = Math.Abs(model.ProcessInfo.Position.Left + arrive.X * -1) * factor.Item1, Y = Math.Abs(model.ProcessInfo.Position.Top + arrive.Y * -1) * factor.Item2 }; NativeHelper.PostMessage(hWnd, WindowMessage.MouseMove, 1, mousePosition.ToLParam()); Task.Delay(10).Wait(); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonUp, 0, mousePosition.ToLParam()); LogHelper.Debug($">>>>Same Drag End Mouse Target X : { mousePosition.X } Target Y : { mousePosition.Y }"); }
private void MouseTriggerProcess(IntPtr hWnd, Point location, IBaseEventTriggerModel model, Tuple <float, float> factor, ProcessConfigModel config) { var mousePosition = new Point() { X = Math.Abs(model.ProcessInfo.Position.Left + (model.MouseTriggerInfo.StartPoint.X + location.X) * -1) * factor.Item1, Y = Math.Abs(model.ProcessInfo.Position.Top + (model.MouseTriggerInfo.StartPoint.Y + location.Y) * -1) * factor.Item2 }; if (model.MouseTriggerInfo.MouseInfoEventType == MouseEventType.LeftClick) { LogHelper.Debug($">>>>LMouse Save Position X : {model.MouseTriggerInfo.StartPoint.X} Save Position Y : {model.MouseTriggerInfo.StartPoint.Y} Target X : { mousePosition.X } Target Y : { mousePosition.Y }"); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonDown, 1, mousePosition.ToLParam()); Task.Delay(100).Wait(); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonUp, 0, mousePosition.ToLParam()); } else if (model.MouseTriggerInfo.MouseInfoEventType == MouseEventType.RightClick) { LogHelper.Debug($">>>>RMouse Save Position X : {model.MouseTriggerInfo.StartPoint.X} Save Position Y : {model.MouseTriggerInfo.StartPoint.Y} Target X : { mousePosition.X } Target Y : { mousePosition.Y }"); NativeHelper.PostMessage(hWnd, WindowMessage.RButtonDown, 1, mousePosition.ToLParam()); Task.Delay(100).Wait(); NativeHelper.PostMessage(hWnd, WindowMessage.RButtonDown, 0, mousePosition.ToLParam()); } else if (model.MouseTriggerInfo.MouseInfoEventType == MouseEventType.Drag) { LogHelper.Debug($">>>>Drag Mouse Save Position X : {model.MouseTriggerInfo.StartPoint.X} Save Position Y : {model.MouseTriggerInfo.StartPoint.Y} Target X : { mousePosition.X } Target Y : { mousePosition.Y }"); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonDown, 1, mousePosition.ToLParam()); Task.Delay(10).Wait(); for (int i = 0; i < model.MouseTriggerInfo.MiddlePoint.Count; ++i) { mousePosition = new Point() { X = Math.Abs(model.ProcessInfo.Position.Left + model.MouseTriggerInfo.MiddlePoint[i].X * -1) * factor.Item1, Y = Math.Abs(model.ProcessInfo.Position.Top + model.MouseTriggerInfo.MiddlePoint[i].Y * -1) * factor.Item2 }; NativeHelper.PostMessage(hWnd, WindowMessage.MouseMove, 1, mousePosition.ToLParam()); Task.Delay(config.DragDelay).Wait(); } mousePosition = new Point() { X = Math.Abs(model.ProcessInfo.Position.Left + model.MouseTriggerInfo.EndPoint.X * -1) * factor.Item1, Y = Math.Abs(model.ProcessInfo.Position.Top + model.MouseTriggerInfo.EndPoint.Y * -1) * factor.Item2 }; NativeHelper.PostMessage(hWnd, WindowMessage.MouseMove, 1, mousePosition.ToLParam()); Task.Delay(10).Wait(); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonUp, 0, mousePosition.ToLParam()); LogHelper.Debug($">>>>Drag Mouse Save Position X : {model.MouseTriggerInfo.EndPoint.X} Save Position Y : {model.MouseTriggerInfo.EndPoint.Y} Target X : { mousePosition.X } Target Y : { mousePosition.Y }"); } else if (model.MouseTriggerInfo.MouseInfoEventType == MouseEventType.Wheel) { LogHelper.Debug($">>>>Wheel Save Position X : {model.MouseTriggerInfo.StartPoint.X} Save Position Y : {model.MouseTriggerInfo.StartPoint.Y} Target X : { mousePosition.X } Target Y : { mousePosition.Y }"); //NativeHelper.PostMessage(hWnd, WindowMessage.LButtonDown, 1, mousePosition.ToLParam()); //Task.Delay(100).Wait(); //NativeHelper.PostMessage(hWnd, WindowMessage.LButtonUp, 0, mousePosition.ToLParam()); //NativeHelper.PostMessage(hWnd, WindowMessage.MouseWheel, ObjectExtensions.MakeWParam((uint)WindowMessage.MKControl, (uint)(model.MouseTriggerInfo.WheelData * -1)), 0); //var hwnd = NativeHelper.FindWindowEx(NativeHelper.FindWindow(null, "Test.txt - 메모장"), IntPtr.Zero, "Edit", null); //var p = new System.Drawing.Point(0, 0); NativeHelper.PostMessage(hWnd, WindowMessage.MouseWheel, ObjectExtensions.MakeWParam(0, model.MouseTriggerInfo.WheelData * ConstHelper.WheelDelta), mousePosition.ToLParam()); } }
private void ImageTriggerProcess(IntPtr hWnd, Point location, IBaseEventTriggerModel model) { var position = new Point() { X = location.X + model.MouseTriggerInfo.StartPoint.X, Y = location.Y + model.MouseTriggerInfo.StartPoint.Y }; LogHelper.Debug($">>>>Image Location X : {position.X} Location Y : {position.Y}"); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonDown, 1, position.ToLParam()); Task.Delay(100).Wait(); NativeHelper.PostMessage(hWnd, WindowMessage.LButtonUp, 0, position.ToLParam()); }