0

In a button click event IEnumerable res;

System.Threading.Thread.Sleep(10000);
var windows = FindWindowsWithText("GrADS 2.0.2.oga.2");
GetWindowThreadProcessId(windows,out res)

Then FindWindowsWithText

public static IEnumerable<IntPtr> FindWindowsWithText(string titleText)
        {
            return FindWindows(delegate(IntPtr wnd, IntPtr param)
            {
                return GetWindowText(wnd).Contains(titleText);
            });
        }

Then in the variable windows i'm getting one count in this case and the handle number: [0] = 3343352

With this number 3343352 i need to find in the end the process in this case external process name and process mainwindowtitle.

Using this

IEnumerable<IntPtr> res;

Not sure if it's any good i thought to get the id and then somehow using the id to get the name and mainwindowtitle. I made a mess.

Haim Shabort
  • 57
  • 10

1 Answers1

0

Simply use process = Process.GetProcessById(id) to get the process by the ID. Then you can use process.MainWindowTitle and process.ProcessName.

Cyral
  • 13,999
  • 6
  • 50
  • 90
  • @HaimShabort Maybe you are looking for something like this? http://stackoverflow.com/a/13547659/1218281 – Cyral Dec 31 '15 at 04:25