我想知道是否可以检测命名外部应用程序的窗口何时启动以及如何启动。
实施例: 当运行firefox或记事本(最好是按进程名称。例如not notepad.exe)时,最小化我的应用程序。
答案 0 :(得分:1)
For each p as process in process.GetProcesses()
If p.processname = "notepad" then
'Do something
Else
'Do Else Something
End If
Next
答案 1 :(得分:1)
这有两种方法可行:
Dim plist() As Process = Process.GetProcessesByName("notepad")
If plist.Length > 0 Then
' notepad is running at least once
Else
' notepad is not running
End If
或
Dim notepadRunning As Boolean = False
For Each p As Process In Process.GetProcesses
If p.ProcessName = "notepad" Then notepadRunning = True
Next
If notepadRunning Then
' notepad is running at least once
Else
'notepad is not running
End If
注意:第二种方式只是第一种方式的美化版本......