Results 1 to 12 of 12

Thread: annoying browser popups

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15
    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

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thumbs up

    Hi Xinny,

    Click here to check out this post that describes how to do what you want to do.

    All the best.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15
    Thanks guys, those replies have given me some ideas. I think I know where to start now.

    Xinny

  5. #5
    Guest
    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?

  6. #6
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600
    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.

  7. #7
    Guest
    But what if he's not using the Webbrowser Control? And it's a regular IE Window, what would you do?

  8. #8
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Matthew,

    now I understand the logic of what you said...and your recommended course of action.

  9. #9
    Guest
    Check out this thread, HeSaidJoe has a link there which shows you how to interact with IE windows.

  10. #10
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  11. #11

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15
    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

  12. #12
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    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
  •  



Click Here to Expand Forum to Full Width