需要模拟鼠标定时点击,远程桌面开启时可以正常运行,点“×”断掉远程后,日志显示到点程序执行了,实际缺没有点击成功。
class MouseFlag
{
enum MouseEventFlag : uint
{
Move = 0x0001,
LeftDown = 0x0002,
LeftUp = 0x0004,
RightDown = 0x0008,
RightUp = 0x0010,
MiddleDown = 0x0020,
MiddleUp = 0x0040,
XDown = 0x0080,
XUp = 0x0100,
Wheel = 0x0800,
VirtualDesk = 0x4000,
Absolute = 0x8000
}
[DllImport("user32.dll")]
static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
[DllImport("user32.dll")]
public static extern int SetCursorPos(int x, int y);
public static void MouseLefClickEvent(int dx, int dy, uint data)
{
SetCursorPos(dx, dy);
mouse_event(MouseEventFlag.LeftDown, dx, dy, data, UIntPtr.Zero);
mouse_event(MouseEventFlag.LeftUp, dx, dy, data, UIntPtr.Zero);
}
}
MouseLefClickEvent(100,100, 0);
标签:
换个简单方便的思路行不行~~!!
你直接远程放个脚本不就搞定了。
问题解决没?
因为没有UI了,没有鼠标键盘驱动了。1.先试试给一个鼠标键盘。
2.再试试,给显示器。