set mouse position via web api action

0

I have a console application in which I move the mouse to a desired position using User32.dll methods import.

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

[Flags]
public enum MouseEventFlags
{
    LEFTDOWN = 0x00000002,
    LEFTUP = 0x00000004,
    MIDDLEDOWN = 0x00000020,
    MIDDLEUP = 0x00000040,
    MOVE = 0x00000001,
    ABSOLUTE = 0x00008000,
    RIGHTDOWN = 0x00000008,
    RIGHTUP = 0x00000010
}

public void MoveBy(int x, int y)
{
    mouse_event((int)(MouseEventFlags.MOVE), x, y, 0, 0);
}

When I use the same method which works for me in the console application from a web api method nothing happens. I tried to change the application pool to my user account which is the one associated with the UI but it didn't help.

Any suggestion how I can accomplish this task?

Thanks in advance!

c#
iis
asp.net-web-api2
pinvoke
asked on Stack Overflow Feb 26, 2016 by Gal Ziv

1 Answer

0

You can't do this through a website, or it might be better to phrase you can't mimic you're results from a console application for a client using a website.

The mouse is controlled by your operating system and neither the server nor the browser will be able to access that functionality on a client's computer.

answered on Stack Overflow Feb 26, 2016 by konkked

User contributions licensed under CC BY-SA 3.0