Expand|Select|Wrap|Line Numbers
- document.elementFromPoint(x, y).click()
Expand|Select|Wrap|Line Numbers
- PageMethods.MouseClick(x, y, mouseClick_Return);
Expand|Select|Wrap|Line Numbers
- [System.Runtime.InteropServices.DllImport("user32.dll")]
- public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
- [System.Runtime.InteropServices.DllImport("user32.dll")]
- [return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
- public static extern bool GetCursorPos(out POINT lpPoint);
- public const int MOUSEEVENTF_LEFTDOWN = 0x02;
- public const int MOUSEEVENTF_LEFTUP = 0x04;
- public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
- public const int MOUSEEVENTF_RIGHTUP = 0x10;
- public const int MOUSEEVENTF_ABSOLUTE = 0x8000;
- [System.Web.Services.WebMethod]
- public static void MouseClick(int x, int y)
- {
- POINT p;
- if (GetCursorPos(out p))
- {
- mouse_event(MOUSEEVENTF_LEFTDOWN & MOUSEEVENTF_ABSOLUTE, p.X, p.Y, 0, 0);
- mouse_event(MOUSEEVENTF_LEFTUP & MOUSEEVENTF_ABSOLUTE, p.X, p.Y, 0, 0);
- }
- else
- {
- mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
- mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
- }
- }
Then I display the image again in the call back to the JavaScript.
This does not seem to work as I expected; the mouse click seems to not do anything. Any guidance would be appreciated.