【问题标题】:Simulate mouse click on a minimized window模拟鼠标点击最小化窗口
【发布时间】:2011-08-11 16:24:33
【问题描述】:
我目前正在用 C# 编写一个应用程序,它将识别屏幕上的某些模式并移动到鼠标单击它。目前,应用程序需要获得焦点和鼠标光标移动,因此在程序运行时计算机无法使用。
我想模拟鼠标在窗口上的点击,但实际上并没有在屏幕上移动鼠标。
我的目标是能够模拟鼠标点击最小化的应用程序。
用 C# 做起来容易吗?
【问题讨论】:
-
您可以使用 PostMessage 来模拟鼠标点击。即使窗口不在焦点上,这也将起作用。阅读此here。
标签:
c#
click
mouse
simulate
【解决方案2】:
试试这个:
public const int SW_MAXIMIZE = 3;
private delegate bool EnumDesktopWindowsDelegate(IntPtr hWnd, int lParam);
[DllImport("user32.dll")]
static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDesktopWindowsDelegate lpfn, IntPtr lParam);
[DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)]
public static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
[DllImport("USER32.DLL")]
public static extern bool ShowWindow(IntPtr hWnd,int nCmdShow);