2011-08-11 53 views
0

我目前正在編寫一個應用程序在C#中,將識別在屏幕上的某些模式,並移動到鼠標點擊它。目前,應用程序需要關注焦點並移動鼠標光標,因此在程序運行時計算機無法使用。 我想模擬鼠標點擊一個窗口,但實際上並沒有在屏幕上移動鼠標。 我的目標是能夠模擬鼠標點擊最小化的應用程序。 在C#中很容易嗎?模擬鼠標點擊一個最小化的窗口

回答

1

試試這個:

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