PDA

Click to See Complete Forum and Search --> : searching window with API


Joe Bob
Dec 5th, 1999, 12:10 AM
Hello again all!

Im having trouble finding the a window in WINDOWS98. I'm using VB5

Here's my problam>

There is a window called "AwtWindow" and it has no text. Let's call this window 1

There is another window called "AwtWindow" and it has no text. Let's call this window 2


Window 1 and Window 2 are diffrent programs.
When I try and find Window2, it finds window 1 first.

I closed window 1 and window 2 is found. But both windows(1 and 2) need to be open for it to work.

How do I find window 2 by skipping around window 1?

Get it??? LoL

Thanks

jkurpias
Dec 5th, 1999, 02:12 AM
I have a lot of API code that may help you.
Send me your current email address and I will forward the code.

Jon

Serge
Dec 5th, 1999, 05:46 PM
It is very easy to find all windows with the same class name (or Caption) using FindWindowEx API. Here is an example:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long


'------Put this on any event
Dim lWindow As Long
Dim iCount As Integer

lWindow = FindWindowEx(0, 0, "AwtWindow", vbNullString)

If lWindow Then
Do While lWindow
iCount = iCount + 1
lWindow = FindWindowEx(0, lWindow, "AwtWindow", vbNullString)
Loop
End If
MsgBox iCount & " windows found."


Assuming that AwtWindow is a class name.

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)