我C#写的程序,想激活一个后台的IE浏览窗口。如何实现?
还有怎么获得他的坐标?
句柄我能获得到。
System.Diagnostics.Process[] myPs;
myPs = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in myPs)
{
string str = p.MainWindowTitle;
if (p.ProcessName.Contains("test"))
{
try
{
IntPtr newIeWindow = p.MainWindowHandle;
}
catch (Exception eKillProcess)
{
}
}
}
还有怎么获得他的坐标?
句柄我能获得到。
System.Diagnostics.Process[] myPs;
myPs = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in myPs)
{
string str = p.MainWindowTitle;
if (p.ProcessName.Contains("test"))
{
try
{
IntPtr newIeWindow = p.MainWindowHandle;
}
catch (Exception eKillProcess)
{
}
}
}
//窗口句柄
windowHandle = (IntPtr)hwnd;
//获取标题
StringBuilder sbuilder = new StringBuilder(256);
NativeMethod.GetWindowText(windowHandle, sbuilder, sbuilder.Capacity);
string strTitle = sbuilder.ToString();
//如果标题相等,则拉至最前面
if (strTitle == ApplicationTitle)
{
NativeMethod.ShowWindow(windowHandle, Const.SW_SHOWNORMAL);
NativeMethod.SetForegroundWindow(windowHandle);
}
public static extern bool SetForegroundWindow(IntPtr hWnd);
你得到句柄就用这个API吧。
SetForegroundWindow(你的句柄);
public static public extern bool SetForegroundWindow(IntPtr hWnd);
public static extern bool SetForegroundWindow(IntPtr hWnd);
你得到句柄就用这个API吧。
SetForegroundWindow(你的句柄);