[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)] private static extern IntPtr FindWindowEx(IntPtr hwndParent, uint hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)] private static extern IntPtr SendMessage(IntPtr hwnd, uint wMsg, int wParam, int lParam); [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Unicode)] private static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, string lParam); [DllImport("user32.dll", EntryPoint = "SetForegroundWindow", SetLastError = true)] private static extern void SetForegroundWindow(IntPtr hwnd);
引入系统API后,就可以使用FindWindow,FindWindowEx,SetForegroundWindow,SendKeys,SendMessage等等来操作应用了~
查系统API就可以搞定大部分工作了~