|
-
Mar 11th, 2004, 09:38 AM
#1
Thread Starter
Frenzied Member
How to detect if window is open ?[resolved]
Well i know how to detect if an app is running by using its caption,
put this in a timer etc,
VB Code:
Dim WinWnd As Long
WinWnd = FindWindow(vbNullString, "app caption")
but take the same app that has two different windows but both have the same caption, well you can identify sections(windows ?) within these windows by their handles.
So how would i code this to detect if a window is open by deteceting a certain part within this window by it handle...lol
Last edited by Jmacp; Mar 11th, 2004 at 04:23 PM.
-
Mar 11th, 2004, 11:03 AM
#2
You may try using EnumWindows api function (not qute sure but give it the shot. Here is a quick sample from allapi.net:
VB Code:
'Add this code to a form
Private Sub Form_Load()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
'Set the form's graphics mode to persistent
Me.AutoRedraw = True
'call the Enumwindows-function
EnumWindows AddressOf EnumWindowsProc, ByVal 0&
End Sub
'Add this code to a module
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim sSave As String, Ret As Long
Ret = GetWindowTextLength(hwnd)
sSave = Space(Ret)
GetWindowText hwnd, sSave, Ret + 1
Form1.Print Str$(hwnd) + " " + sSave
'continue enumeration
EnumWindowsProc = True
End Function
-
Mar 11th, 2004, 11:22 AM
#3
Thread Starter
Frenzied Member
I think you use this, which indeed finds the main window fine but doesnt seem to recognise the child window ,
VB Code:
findmain = FINDWINDOW("class in here", vbNullString)
findchild = FindWindowEx(findmain, 0&, "class in here", vbNullString)
So i have the right class of the child(from spy++) and it finds the main window fine, why wouldnt it find the child window?
-
Mar 11th, 2004, 01:23 PM
#4
-
Mar 11th, 2004, 04:22 PM
#5
Thread Starter
Frenzied Member
I made a typo [resolved].
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|