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. Currently, the application needs to have the focus and the mouse cursor moves, so the compu开发者_JS百科ter is unusable while the program is running. I would like to simulate a mouse click on a window but without actually moving the mouse on the screen. 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#?
You should read about using Windows API from .NET (PInvoke). Start with these:
http://msdn.microsoft.com/en-us/library/bb775985(v=vs.85).aspx
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);
精彩评论