Get title from a processes name

October 29, 2011 at 20:24:03
Specs: Windows 7 SP1, 2.814 GHz / 4 GB
I've made a little C# program to send a keystroke to Media Player Classic to play/pause it. I'll leave the usage of this program to your imaginations.

My question is how can I get the title of a program by it's exe name.

In order to send keystrokes the target program has to be active and the method I have for switching a program to being active takes the title of the program. Which for MPC is usually the currently playing filename, however you can change an option to set it as "Media Player Classic Home Cinema". I'd rather not have to set MPC's title to be static and would prefer to have it show the currently playing filename. So I need a way to get the title of the currently running mpc-hc.exe.

See More: Get title from a processes name

Report •

October 29, 2011 at 20:34:18
Yet again I find the answer right after I ask the question.

C# example
var info = Process.GetProcessesByName("mpc-hc").FirstOrDefault();
if (info != null) MessageBox.Show(info.MainWindowTitle);

Report •
Related Solutions

Ask Question