Solved

Destroying browser windows

Posted on 1999-01-08
26
170 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
Comment Utility
Sounds like API calls to me. I'll go check it out.
0
 

Author Comment

by:timjc
Comment Utility
Edited text of question
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
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
 

Author Comment

by:timjc
Comment Utility
Mirkwood,

What do you mean by class name ?
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Do a sendmessage with WM_DESTROY or call DestroyWindow (API) with the hwnd as parameter.

0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
Mirkwood is correct.  Or you could send a WM_CLOSE message.
0
 

Author Comment

by:timjc
Comment Utility
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
Comment Utility
Unfortunately, with VB, the answer is no.  Sorry.
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
clifABB,

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

Cheers.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now