mouse_event WinAPI call not working when cursor is over Flash
- by friederbluemle
Hi,
I am writing a small program which can simulate mouse clicks at specified positions.
Using the Win32 API call mouse_event like so:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
[Flags]
public enum MouseEventFlags : uint
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
mouse_event((uint)(MouseEventFlags.LEFTDOWN | MouseEventFlags.LEFTUP), x, y, 0, UIntPtr.Zero);
Works perfectly fine, except when the mouse cursor is over a Flash application. Flash seems to ignore the simulated mouse click.
What could be the reason for this? And how do I fix it?
Thank you!