Solved

Destroying browser windows

Posted on 1999-01-08
26
173 Views
Last Modified: 2010-05-03
Please can someone supply me with code that does the following:

a) Display a list of windows by title bar, open in a web browser (I use Netscape)

b) The ability to kill any window from that list.

If this can be done, it would help me rid those small annoying adverts and other other unwanted additional windows immediately that pop up when I enter certain sites. Currently I sometimes have to wait for the damn things to load before I can quit them!

Loadsa points coming your way if I'm supplied with comprehensive example from you.

Thanks,
Tim

P.S. I'm using VB 5.0 Enterprise
0
Comment
Question by:timjc
  • 10
  • 9
  • 6
  • +1
26 Comments
 
LVL 2

Expert Comment

by:cartti
ID: 1454911
Sounds like API calls to me. I'll go check it out.
0
 

Author Comment

by:timjc
ID: 1454912
Edited text of question
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454913
Mail me after a couple of days when nobody has given a solution. I'll do it.
Meanwhile a task for you. I need to know what the class name is of the topwindow of Netscape. You can find that with a application like "spy".
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:timjc
ID: 1454914
Mirkwood,

What do you mean by class name ?
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454915
Each window has a class name. This class name is important to find the window.
Take a look at the API FindWindow
0
 

Author Comment

by:timjc
ID: 1454916
I'm not 100% certain of all this, but I managed to download some code that returns the class name of every window. The class name changes slightly whenever I reboot Netscape. It may contain a memory address or something like that. The class name on one occasion for the solo Netscape window was Afx: 400000:b:100008:6:13d403ae

The code I used is on this page:http://www.mvps.org/vbnet/code/callback/enumwindows.htm
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454917
If the class name doesn't work (I can't see how, but then it's Netscape), you could use the caption for the window instead.  The first word of the caption should be "Netscape", right?
0
 

Author Comment

by:timjc
ID: 1454918
clifABB,

That's a nice alternative you've suggested. I have the code that lists the window titles that go with the class names. I suppose I could do a filter on those windows with the word Netscape in the title. All I need to know is how you end its existence.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454919
Do a sendmessage with WM_DESTROY or call DestroyWindow (API) with the hwnd as parameter.

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454920
Mirkwood is correct.  Or you could send a WM_CLOSE message.
0
 

Author Comment

by:timjc
ID: 1454921
Thanks you two. One last thing, is there an event or something similar that can be triggered when a new window has been created/ destroyed ? This would save me having to use a timer to give the user an updated list of Netscape windows should one pop up. I consider the timer a messy way of doing this.

Thanx again
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454922
Unfortunately, with VB, the answer is no.  Sorry.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454923
clifABB is right. In VB this is not possible. I used to believe otherwise, but it is not possible to make a systemwide hook using VB.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454924
Actually, thinking about it, the subclass control in Spyworks from Desaware (www.desaware.com), just might allow a system hook.
I haven't used Spyworks in a few years, but you might want to look into it.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454925
No, NO, NOOO. Subclassing only works with the current process out the process you need a callback function that should be exported by a DLL. VB can't export functions, therefor VB cannot make a system wide hook.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454926
Mirkwood:
I'm sorry, I refered to Spyworks subclass control, I meant to refer to the subclass control, which does allow system wide hooks.  It's written in C++ so it doesn't have VB's limitations.  Please refer to the Desaware web site for explainations.
In a previous life, I created an application that "subclassed" another app.  Sort of an Add-in, before there were add-ins.  I used the callback control for this.
Unless Spyworks has changed dramatically in the last couple of years, it will accept a system hook.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454927
A couple of year ago. Maybe in win31?
BTW: an ocx is always embedded in either an exe or a dll. I can't expose exports on its own.
0
 

Author Comment

by:timjc
ID: 1454928
I've managed to write an application using your ideas. I've made it a bit more useful than just referring to Netscape windows. Would you like a look ? Please suggest a decent way of posting an exe to both of you.

I would like to share the points, but alas EE is limited in this respect. Any suggestions ?
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454929
As far as sharing ponts, you can post a request in the customer service area asking Linda to do that.
Personally, though, I'm not in this just for the points, so if you want to just award Mirkwood the points, that's fine.
0
 

Author Comment

by:timjc
ID: 1454930
I'll take that as a polite 'no I don't won't to see it'. Never mind.

Someone post anything as an answer (bar cartti) and I'll get customer services to split the points.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454931
I'm sorry, I missed the your request to view your app.
You might be able to upload it to my ftp site (ftp.duck.org).  I would be happy to take a look and tell you what I think.
Log in to the site with 'anonymous' as the user name and your email as the password
0
 

Author Comment

by:timjc
ID: 1454932
cliffABB,

I have WS_FTP pro. I've tried logging on using your parameters. Unfortunatley, it comes back with the message Can't get "ftp.duck.org" host entry...

I can bring up the site in a browser, so I don't think it has to do with anything on your side. However, could you give me instructions on how to log on in WS_FTP ?

Did you mean I should use my own e-mail address as a password, rather than post you my e-mail address for a password ?

Tim
0
 

Author Comment

by:timjc
ID: 1454933
clifABB,

I have WS_FTP pro. I've tried logging on using your parameters. Unfortunatley, it comes back with the message Can't get "ftp.duck.org" host entry...

I can bring up the site in a browser, so I don't think it has to do with anything on your side. However, could you give me instructions on how to log on in WS_FTP ?

Did you mean I should use my own e-mail address as a password, rather than post you my e-mail address for a password ?

Tim
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1454934
With WS_FTP, there is an option button in the connect screen that will allow you to specify that the login type will be 'anonymous ftp'.  It will automatically use 'anonymous' as a login and your email as a password.  All other settings should just stay at whatever their default is.
0
 
LVL 6

Accepted Solution

by:
clifABB earned 250 total points
ID: 1454935
I read your post in the customer service area (I assume you were referring to this thread), so I'll post an answer to this question to get the ball rolling.

If I assumed wrong, you may reject this answer.

Thanks.
0
 

Author Comment

by:timjc
ID: 1454936
clifABB,

Just for the record, I did mention my intentions here.

Cheers.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maro to copy and paste from one worksheet to another based on a condition 11 55
Spell Check in VB6 13 127
VB6 ListBox Question 4 49
Automatic Email Reminder 4 58
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

830 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