Click here to Skip to main content
16,016,580 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In fact this is two question, but those is all about mouse operate.
I want to code a small tool which can simulate mouse operates, such as drag a file to a new position.
But I don't know how to get the mouse click position, as I want to record the mouse operation. and I don't know how to simulate mouse drag. Can anyone give me some ideas. Thanks very much.
P.S. For mouse drag, I tried this method but it won't work:
C#
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
        public const int MOUSEEVENTF_LEFTDOWN = 0x2;
        public const int MOUSEEVENTF_LEFTUP = 0x4;

MIDL
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Cursor.Position = new System.Drawing.Point(x, y); //X,Y is the new position
                 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Posted
Updated 1-Dec-19 2:04am

1 solution

Hope this may help

link[^]
 
Share this answer
 
Comments
Christian Amado 18-Jul-14 11:31am    
Google always the best friend.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900