mouse_event WinAPI call not working when cursor is over Flash

Posted by friederbluemle on Stack Overflow See other posts from Stack Overflow or by friederbluemle
Published on 2010-04-03T19:13:13Z Indexed on 2010/04/03 19:23 UTC
Read the original article Hit count: 895

Filed under:
|
|
|

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!

© Stack Overflow or respective owner

Related posts about c#

Related posts about winapi