我希望从进程名称转到windows标题。
e.g
'winamp.exe' - > “1。布兰妮斯皮尔斯 - 再一次打我的宝贝'
由于
解决方案:
Dim p As Process
For Each p In Process.GetProcessesByName("winamp")
MsgBox(p.MainWindowTitle.ToString)
Next
答案 0 :(得分:1)
查看System.Diagnostics.Process
课程:
Process p = <Get process>
Console.WriteLine(p.MainWindowTitle)
答案 1 :(得分:0)
以下是如何获取主标题栏中显示的文件名。这是没有扩展名的文件名。假设我的Excel工作簿名为“ThisWorks.xlsx”,此代码返回“ThisWorks”而没有文件扩展名。
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返回从0(零)开始的整数数组。如果您知道进程所在的顺序,则可以返回所需目标的标题/文件名。
希望这有帮助...花了我3个星期才找到这个答案。