Filtering Existing windows

wavemasta

Member
Joined
Feb 12, 2009
Messages
12
Programming Experience
10+
Hi:

One of the features of the application I am working for is that it needs to check if an external windows application..lets call it A, is running. If it isn't running, then start it. If it is, then leave it.
My idea originally was to use the process name as a filter. But the problem is that the process for application A is javaw.exe. Application A, belongs to a toolset, which has other windows applications, which have the same process name, javaw.exe.
I already know that one of windows which has a javaw.exe process has "Edit"..in its title bar. So my algorithm to filter for app A is:

1. GetAllExistingOpenWindows
2. For each window in AllExistingOpenWindows
3. if window.processname=="javaw.exe" then
if window.getheader.doesnotcontain("Edit")

then
it means this is what I want (App A is running), and I dont have to do anything.

else
it means app A isn't running and I need to start it.

end if

end if

The issue is, there are a lot of things I can't implement...particularly steps 1, 2, and 3..and I have done a lot of googling.:)

Can anyone help, or please point me in the right direction?

I apologize in advance if I posted this in the wrong section of this forum. i wasn't sure where to put this.

Regards
 
If you are interested, I solved the problem. I realised I didn't have to look at all the windows, because the process had a MainWindowTitle Property...which I used...so that was what I used...the fact that another process with the same "javaw.exe" process might exist didn't matter because I used the MainWindowTitle Property as a filter.

So what I did was....

Dim p As New Process()

'first lets check if the Application is already running.
'check all processes
For Each p In Process.GetProcesses(".")
If Not p.MainWindowTitle.ToString.Contains("Window Text") Then
'A is not activated, so activate it.
Try
Dim operatorprocess As New System.Diagnostics.Process
Dim opstartinfo As New ProcessStartInfo("blah")
operatorprocess.StartInfo = opstartinfo
operatorprocess.Start()
Catch ex As Exception

End Try
Else
'A is running, so do nothing

End If

Next
 
Back
Top