Solved

Get window handle

Posted on 1998-10-15
3
566 Views
Last Modified: 2013-12-03
Is there a way to get the handle for eg. the Netscape window. FindWindow won't work here, since I don't know what the title of the window would be (netscape inserts the title of the page in the title)
0
Comment
Question by:carceri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:jusdes
ID: 1415282
this is how you find the msie windows + buttons i answered the other one with the netscape.

a% = FindWindow("IEFRAME", vbNullString)
b% = FindChildByClass(a%, "Worker")
c% = FindChildByClass(b%, "ReBarWindow32")
d% = FindChildByClass(c%, "SysPager")
E% = FindChildByClass(d%, "ToolbarWindow32")
F% = FindChildByClass(c%, "ComboBoxEx32")
g% = FindChildByClass(F%, "ComboBox")
H% = FindChildByClass(g%, "Edit")

these are the functions you might need:

Function FindChildByClass(parentw, childhand)
firs% = GetWindow(parentw, GW_MAX)
If UCase(Mid(GetClass(firs%), 1, Len(childhand))) Like UCase(childhand) Then GoTo Greed
firs% = GetWindow(parentw, GW_CHILD)
If UCase(Mid(GetClass(firs%), 1, Len(childhand))) Like UCase(childhand) Then GoTo Greed
While firs%
firss% = GetWindow(parentw, GW_MAX)
If UCase(Mid(GetClass(firss%), 1, Len(childhand))) Like UCase(childhand) Then GoTo Greed
firs% = GetWindow(firs%, GW_HWNDNEXT)
If UCase(Mid(GetClass(firs%), 1, Len(childhand))) Like UCase(childhand) Then GoTo Greed
Wend
FindChildByClass = 0
Greed:
room% = firs%
FindChildByClass = room%
End Function

Function FindChildByTitle(parentw, childhand)
firs% = GetWindow(parentw, 5)
If UCase(GetCaption(firs%)) Like UCase(childhand) Then GoTo Greed
firs% = GetWindow(parentw, GW_CHILD)
While firs%
firss% = GetWindow(parentw, 5)
If UCase(GetCaption(firss%)) Like UCase(childhand) & "*" Then GoTo Greed
firs% = GetWindow(firs%, GW_HWNDNEXT)
If UCase(GetCaption(firs%)) Like UCase(childhand) & "*" Then GoTo Greed
Wend
FindChildByTitle = 0
Greed:
room% = firs%
FindChildByTitle = room%
End Function
0
 

Author Comment

by:carceri
ID: 1415283
Sorry.. my mistake that I posted this question twice. Thanks anyway...
0
 

Accepted Solution

by:
Zainal062797 earned 70 total points
ID: 1415284
If you are using Visual C++, use "Spy++" to look for the class name. i.e. I use Internet Explorer, and the class name is IEFrame.
Use findWindow() to get a handle for the window:
  Handle = FindWindow (CLassName, NULL) ;
Make sure you pass a null string for the title since it changes all the time.
If you don't use Visual C++, your compiler would have something similar.

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question