ClassName or WindowName

G

Guest

How do you find the classname or window name of a program. Tom O. gave me some code to check and see if a program is open. We used notpad as the example. The code works great, however when I try to aply this to another program it doesnot work. I think it is becasue I have the wrong classname for the program. I am posting the code that Tom posted for me. TI

Private Declare Function FindWindow
Lib "user32"
Alias "FindWindowA"
(
ByVal lpClassName As String,
ByVal lpWindowName As String
)
As Lon

Sub CheckNotepad(
Dim hwnd As Lon
hwnd = FindWindow("Notepad", vbNullString
If hwnd <> 0 The
MsgBox "Notepad is running
Els
MsgBox "Notepad is not running
End I
End Sub
 
F

Frank Kabel

Hi
have a look at the Windows Taskmanager. Use the name which appears in
this dialog.
 
T

Tom Ogilvy

This is a pretty comprehensive article that you might find helpful. I don't
know it you want to dynamically find the window in your code, or only need
to discover what the class name is so you can use it in the original code.
In either case, you could modify the code in the article to provide the
information. If you only want to know what it is, if you have Visual
Studio, it comes with a utility called spy++ which would allow you do
examine and get such information if the application is running.

http://support.microsoft.com/default.aspx?scid=kb;en-us;147659&Product=vbb
HOWTO: Get a Window Handle Without Specifying an Exact Title

--
Regards,
Tom Ogilvy



Kevin said:
How do you find the classname or window name of a program. Tom O. gave me
some code to check and see if a program is open. We used notpad as the
example. The code works great, however when I try to aply this to another
program it doesnot work. I think it is becasue I have the wrong classname
for the program. I am posting the code that Tom posted for me. TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top