I am looking to go from the process name to the windows title.
e.g
\'winamp.exe\' -> \'1. Britney Spears - Hit me baby one more time\'
Thanks
Sol
Have a look at the System.Diagnostics.Process class:
Process p = <Get process>
Console.WriteLine(p.MainWindowTitle)
Here's how to get the Filename as displayed in the Main Title Bar. This is the filename without the extension. Let's say that my Excel Workbook was named "ThisWorks.xlsx" This code returns "ThisWorks" without the file extension.
Function OpenAppFileNames(ByVal exeName As String) As String
Dim p() As Process = System.Diagnostics.Process.GetProcessesByName(exeName)
Dim i As Integer = 0
Dim x As Integer = UBound(p) + 1
Dim Index As Long = 0
Dim Title As String = ""
Dim Result As String = ""
Debug.Print(x)
Do
If i = x Then
Exit Do
End If
Title = p(i).MainWindowTitle
Result += vbNewLine & "Index " & Index + i & " = " & Title
i = i + 1
'MsgBox(Result)
Loop Until i = x
Return Result
End Function
p returns an array of integers starting at 0 (zero). If you know which order the processes are in, you can return the Title/Filename of the desired target.
Hope this helps... took me 3 weeks to find this answer.