Programmatically not able to click or move mouse cursor on Active Directory Users and Computers(DSA.MSC) located in Windows Server 2012 R2 RRS feed

  • Question

  • Hi Team,

               I have an application which will move mouse cursor and make click at a desired point. but I am not able to move mouse cursor on Active Directory Users and Computers(DSA.MSC).  And also I am not able to send text or make a mouse click. Same I did in Windows 8.1 Pro which is working fine.

    Please advice me to make this possible.

    I've tried

        public const int MOUSEEVENTF_LEFTDOWN = 0x02;
            public const int MOUSEEVENTF_LEFTUP = 0x04;

            public void Click()
                int x = Cursor.Position.X;
                int y = Cursor.Position.Y;
                mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
                mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);

     Cursor.Position = new Point(Cursor.Position.X + 25, Cursor.Position.Y  );









            [DllImport("user32.dll", EntryPoint = "SetCursorPos")]

            [return: MarshalAs(UnmanagedType.Bool)]


    privatestaticexternboolSetCursorPos(intX, intY);


            [return: MarshalAs(UnmanagedType.Bool)]



    private voidMouseMove()





    point.X += 20;

    SetCursorPos(point.X, point.Y);




    Wednesday, September 5, 2018 1:42 PM

All replies

  • Offhand, this feels like a dodgy thing you are trying to do.

    My best guess is that you are running into UIPI which prevents low integrity processes from manipulating the UI of elevated processes.

    • Edited by SimonRev Wednesday, September 5, 2018 7:55 PM
    Wednesday, September 5, 2018 7:54 PM
  • I need to automate Active Directory Users and Computers(DSA.MSC) which is located in Windows Server 2012 R2,

    Same I did in Windows 8.1 Pro.

    Kindly try in Windows Server 2012 R2

    by using above code, which is working in other environment and other places in Windows Server 2012 R2.

    Dhanasekar. V

    Thursday, September 6, 2018 6:12 AM
  • Hi Dhanasekar Velayudham,

    I try to test the code. But I could not reproduce the error. Could you provide more code?

    According to your description, how do you make it related to DSA.MSC?

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 19, 2018 8:14 AM