Search code examples
c#windowpidautoit-c#-wrapper

get window title from pid


I am looking for a way to get the window title from process id.

I would like to build function the get the pid of specific window and return its window title.

I try to use AutoIt but it didn't work.

Any Idea?


Solution

  • This should be quite simple:

    Process.GetProcessById(processId).MainWindowTitle;
    

    And if you like it as a function as you requested:

    public string GetWindowTitle(int processId){
      return Process.GetProcessById(processId).MainWindowTitle;
    }