|
-
Oct 3rd, 2000, 12:18 AM
#1
Thread Starter
New Member
Hi,
I was wondering if there is a way to kill those browser ad popups.. (geocities etc.) either by allowing only one browser window to be open, or by killing the extra ad windows from a list. I have been trying to write a little program to do this as my first VB project but it is a bit beyond me at the moment. I know there are a couple programs out there that do this but this is a learning experience for me (I hope). All help is appreciated.
Thanks,
Xinny
-
Oct 3rd, 2000, 10:08 AM
#2
Frenzied Member
You could search for all the windows captions, then get the hWnd of each of those windows. Then create a list of those captions, finally when a user selects a window to close, the porgram sends a message to the hWnd to destroy the window.
I have never made a program exactly like this so I have no code for you but I know there are pleanty of examples on this form just search for them.
Search for findwindow, and sendmessage these are the two main API's you would be using.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Oct 3rd, 2000, 11:09 AM
#3
Fanatic Member
Hi Xinny,
Click here to check out this post that describes how to do what you want to do.
All the best.
-
Oct 3rd, 2000, 07:30 PM
#4
Thread Starter
New Member
Thanks guys, those replies have given me some ideas. I think I know where to start now.
Xinny
-
Oct 3rd, 2000, 08:43 PM
#5
That post seems so long ago. I'm curious OneSource, did that shutting down and restarting help?
And Xinny, you have to actually find the window by it's title. Like make a list of popups to ignore and find them and close them. It's not like they have a certain kind of code that will close them. That would make life easier though, wouldn't it?
-
Oct 3rd, 2000, 10:46 PM
#6
Fanatic Member
Matthew,
If I recall correctly, I don't think that the shutting down and restarting helped. But the pop-ups do appear now, maybe because I've downloaded a few IE patches since then, which may have reset some default values.
And Xinny, you have to actually find the window by it's title. Like make a list of popups to ignore and find them and close them.
Matthew, why is this necessary? The thread that I referenced above (that you provided the code for) doesn't require any specific naming of pop-up windows in order to close them.
All the best.
-
Oct 3rd, 2000, 10:50 PM
#7
But what if he's not using the Webbrowser Control? And it's a regular IE Window, what would you do?
-
Oct 3rd, 2000, 11:03 PM
#8
Fanatic Member
Matthew,
now I understand the logic of what you said...and your recommended course of action.
-
Oct 4th, 2000, 06:20 AM
#9
Check out this thread, HeSaidJoe has a link there which shows you how to interact with IE windows.
-
Oct 4th, 2000, 10:49 AM
#10
Frenzied Member
Hey I like the Matthew's aproach, I think you can enumerate all windows with the following code from Megatron
Code:
'[begin of code]
'Author: Megatron
'Origin: VbWorld forums
'Purpose: Enumerate all windows
'Version: VB5+
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
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim Buffer As String
Dim Temp As String
Static iCount As Integer
iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1
If Length > 1 Then
Buffer = Space(Length)
GetWindowText hwnd, Buffer, Length
Temp = Left(Buffer, Length - 1)
'Replace MyTitle with the title of the window you want to find
If Temp Like "*MyTitle*" Then MsgBox ("Window Found")
End If
EnumWindowsProc = 1
End Function
'Code for a Form with a CommandButton
'Private Sub Command1_Click()
' EnumWindows AddressOf EnumWindowsProc, 0
'End Sub
'[end of code]
Then you could use some code from Matthew to kill a proces (do a search on this forum) to close the window.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 5th, 2000, 01:43 AM
#11
Thread Starter
New Member
Matthew,
I had a look at that thread and it'll be very helpful. Also, that snippet OneSource hooked me up with:
Private Sub webbrowser1_NewWindow2...etc etc
It'll help as my next learning project is going to be a little web browser.
Jop,
I've tried the code from Megatron and it should work perfectly. Right now I'm working on a way to "yoink" the titles from an ini file and check for windows to close. I've only been learning VB for about a month so it's quite a slow process, fun though
Thanks again to all of you,
Xinny
-
Oct 5th, 2000, 07:08 AM
#12
Fanatic Member
Webbrowser
Xinny,
When you get ready to do your webbrowser project, you may want to begin with the "webbrowser form" that's provided in VB 6 (I don't know if it's in earlier versions). A lot of the functionality that you would want to include in your application is already in that form. This may defeat the purpose of doing it on your own somewhat, but why re-invent the wheel? Besides, you can concentrate on adding super-duper complex stuff to your app. 
All the best.
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
|