while (true){ Thread.Sleep(1000); //Because of high CPU. foreach (Process currentProcess in Process.GetProcesses()) { if (currentProcess.MainWindowTitle.Contains("Something")) { //Window has been found. } }}
while (true){
Thread.Sleep(1000); //Because of high CPU.
foreach (Process currentProcess in Process.GetProcesses()) { if (currentProcess.MainWindowTitle.Contains("Something")) { //Window has been found. } }}
//Dll imports:[DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Ansi)]private static extern IntPtr FindWindow(string className, string windowName);[DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Ansi)]private static extern bool GetWindowText(IntPtr hWnd, [OutAttribute()] StringBuilder strNewWindowName, Int32 maxCharCount);//And then:while (true){ Thread.Sleep(1000); //Because of high CPU. FileStream stream = new FileStream(@"some path\info.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter writer = new StreamWriter(stream); StringBuilder sbWinText = new StringBuilder(256); GetWindowText(FindWindow(null, "Some text in title"), sbWinText, 256); writer.WriteLine(sbWinText.ToString()); writer.Close();}