.EXE窗口中的鼠标模拟
Mouse Simulation In .exe window
我想制作鼠标宏。这既可以进行模拟的鼠标事件,也可以在屏幕上使用我的计算机自己的光标。
应通过输入IDE中的方法来创建宏。然后,这些方法应在某个.EXE的窗口上执行鼠标事件。通过使用坐标。
例如,这是我执行模拟或未模拟鼠标的方法的目标
psuedo代码:
//Following method left clicks with the offset (x, y)
//from the windows top left corner. If the bool isSimulated
//is set to true the click will be simulated else the computers
//own mouse cursor will be moved and execute the mouse event.
LeftMouseClickOnWindow(x, y, isSimulated);
要进一步解决问题,模拟鼠标clicks 在窗口最小化或未关注时应起作用。
。我想知道创建这种uti的最佳方法是什么。
user32.dll的功能是一种很好的方法吗?
在C 而不是C#?
中进行操作更容易任何建议,来源,示例代码和评论都受到热烈赞赏!
C 和C#都很棒。Autohotkey可以完成这项工作,但我就像您一样 - 我喜欢写自己的东西。另一个选项是自动选择,您可以在C#项目中使用其dll
...但是您必须确保它已安装在每个系统上...不是我经常遇到的奢侈品。
这是可以玩的东西。希望它会让您前进...请注意,它是C#。在运行此代码之前,请确保您在鼠标处于位置的地方没有任何重要的打开...这将在对角线向右下方移动20次,并在每次移动时执行单击。您不希望这意外关闭您的东西。因此,在运行此之前,只需最小化所有内容即可。
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ConsoleApplication
{
class Program
{
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
//private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
//private const int MOUSEEVENTF_RIGHTUP = 0x10;
public void DoMouseStuff()
{
Cursor.Current = new Cursor(Cursor.Current.Handle);
var point = new Point(Cursor.Position.X, Cursor.Position.Y);
for (int i = 0; i < 20; i++, point.X += 10, point.Y += 10)
{
Cursor.Position = point;
Program.mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0);
System.Threading.Thread.Sleep(100);
}
}
static void Main(string[] args)
{
var prog = new Program();
prog.DoMouseStuff();
}
}
}
您需要为System.Windows.Forms
&amp;设置引用System.Drawing
,如果您还没有设置。我将其作为控制台应用程序,因此需要为我设置。当您注意到,我包括System.Threading.Thread.Sleep(100);
...这是这样您可以看到发生了什么。因此,我基本上正在放慢整个过程。它会移动,并且每次移动时都会单击(每100毫秒大约每100毫秒)。
熟悉Cursor
和user32.dll
。
最后但并非最不重要的一点是,这是鼠标&amp;键盘模拟:http://msdn.microsoft.com/en-us/library/ms171548.aspx
- 如何在C++中模拟鼠标光标的移动
- 如何在后台模拟鼠标单击到 DirectX 应用程序?
- .EXE窗口中的鼠标模拟
- 处理 iOS 触摸以模拟鼠标以C++输入库
- 模拟鼠标按钮按QT 5.3仅第一次工作
- 在使用发送输入 API 模拟鼠标单击时是否需要引入延迟
- C++模拟鼠标左键单击最小化程序
- 如何用Qt模拟鼠标事件
- 有没有一种方法可以模拟从鼠标右键菜单发送到控制台的调用
- 无线键盘/鼠标应用程序:模拟击键
- 如何模拟当前打开窗口的鼠标滚动
- 在Qt中生成(模拟)假鼠标事件
- 以C++模拟鼠标和键盘输入
- 模拟鼠标单击而不移动光标
- 如何将控制器模拟棒映射到鼠标
- c++鼠标点击模拟代码
- 如何在Linux和Windows上的Qt中模拟所有鼠标和键盘事件
- 是否有可能模拟鼠标移动和鼠标点击隐藏窗口
- 如何模拟鼠标移动
- SendInput -(鼠标移动模拟)