C# Event mouse left and move

Issue

This Content is from Stack Overflow. Question asked by Đức Cường

Can someone help me complete my code , i don’t know how to click and move the image
I found on google the code

 [DllImport("user32.dll")]
    static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

    [Flags]   
    public enum MouseEventFlags
    {
        LEFTDOWN = 0x000000002,
        LEFTUP = 0x000000004,
        MIDDLEDOWN = 0x000000020,
        MIDDLEUP = 0x000000040,
        MOVE = 0x000000001,
        ABSOLUTE = 0x000008000,
        RIGHTDOWN = 0x000000008,
        RIGHTUP = 0x000000010,
    }
    public void mousedown(Point p)
    {
        Cursor.Position = p;
        mouse_event((int)(MouseEventFlags.LEFTDOWN), 0, 0, 0, 0); 
    }

Code find image and move it

        private void btntestcode_Click(object sender, EventArgs e)
    {
        var screen = CaptureHelper.CaptureScreen();

        var subBitmap = ImageScanOpenCV.GetImage("testmousemove.PNG");

        var resBitmap = ImageScanOpenCV.FindOutPoint((Bitmap)screen, subBitmap);
        if (resBitmap != null)
        {
            mousedown((Point)resBitmap);
            
        }
    }



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?