简体   繁体   English

模拟鼠标点击最小化的 window

[英]Simulate mouse click on a minimized window

I am currently writing an application in C# that will recognize certain patterns on the screen and move to mouse to click on it.我目前正在 C# 中编写一个应用程序,它将识别屏幕上的某些模式并移动到鼠标单击它。 Currently, the application needs to have the focus and the mouse cursor moves, so the computer is unusable while the program is running.目前,应用程序需要有焦点和鼠标 cursor 移动,所以程序运行时计算机无法使用。 I would like to simulate a mouse click on a window but without actually moving the mouse on the screen.我想模拟在 window 上的鼠标单击,但实际上没有在屏幕上移动鼠标。 My goal would be to be able to simulate mouse click on a application that is minimized.我的目标是能够模拟鼠标点击最小化的应用程序。 Would that be easy to make in C#?在 C# 中容易做到吗?

You should read about using Windows API from .NET (PInvoke).您应该从 .NET (PInvoke) 中阅读有关使用 Windows API 的信息。 Start with these:从这些开始:

http://msdn.microsoft.com/en-us/library/bb775985(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/bb775985(v=vs.85).aspx

http://www.codeguru.com/forum/showthread.php?t=427934 http://www.codeguru.com/forum/showthread.php?t=427934

try this:尝试这个:

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM