Example #1
0
 public static extern bool GetCursorPos(out POINT lpPoint);
Example #2
0
        public static void simulateClickMechanically(WindowDetection.Structure ws, Point position, bool exact)
        {
            IntPtr previousTopWindow = WindowDetection.GetForegroundWindow();
                WindowDetection.SetForegroundWindow(ws.mainWindow);
                WindowDetection.SetFocus(ws.mainWindow);
                System.Threading.Thread.Sleep(25);

                POINT p = new POINT();
                GetCursorPos(out p);

                position.X += ws.position.Left;
                position.Y += ws.position.Top;

                Point clickPos = prepareClickPoint(ws, position, exact);

                SetCursorPos(clickPos.X, clickPos.Y);
                System.Threading.Thread.Sleep(1);

                mouse_event(MouseEventFlags.MOUSEEVENTF_LEFTDOWN, (uint)clickPos.X, (uint)clickPos.Y, (uint)0, UIntPtr.Zero);
                mouse_event(MouseEventFlags.MOUSEEVENTF_LEFTUP, (uint)clickPos.X, (uint)clickPos.Y, 0, UIntPtr.Zero);

                SetCursorPos(p.X, p.Y);

                WindowDetection.SetForegroundWindow(previousTopWindow);
                WindowDetection.SetFocus(previousTopWindow);
        }