//窗口标题判断**************
if (GetActiveWindowTitle() == "棕化线监控软件") MessageBox.Show("ok");
//窗口标题判断**************
//*************下面是获取活动窗体标题名的函数代码*****
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
private string GetActiveWindowTitle()
{
const int nChars = 256;
IntPtr handle = IntPtr.Zero;
StringBuilder Buff = new StringBuilder(nChars);
handle = GetForegroundWindow();
if (GetWindowText(handle, Buff, nChars) > 0)
{
return Buff.ToString();
}
return null;
}
//*************下面是获取活动窗体标题名的函数代码*****