I would like to know if it is possible to detect when the window of a named external application is launched and how to.
Example: When firefox or notepad(preferably by process name. Not notepad.exe for example) is ran, minimize my application.
Here two ways, that would work:
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
or
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
Note: the second way is just a glorified version of the first...