mouse_event WinAPI的呼叫不工作时,光标在闪光 [英] mouse_event WinAPI call not working when cursor is over Flash
本文介绍了mouse_event WinAPI的呼叫不工作时,光标在闪光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
结果
我写一个小程序,可以在指定的位置模拟鼠标点击。
使用Win32 API调用mouse_event像这样:
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);
工作完全正常,除了当鼠标光标位于Flash应用程序 。闪存似乎忽视了模拟鼠标点击。
可能是什么原因呢?而如何解决呢?
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?
感谢您!
推荐答案
尝试
mouse_event((uint)
(MouseEventFlags.LEFTDOWN | MouseEventFlags.LEFTUP | MouseEventFlags.ABSOLUTE),
x, y, 0, UIntPtr.Zero);
此外,对于一些奇怪的原因,我曾与以上P问题/ Invoke的调用约定,请参见 http://stackoverflow.com/questions/1740045/simulating-一个鼠标键点击式窗口/ 3002585#3002585
这篇关于mouse_event WinAPI的呼叫不工作时,光标在闪光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文