Results 1 to 16 of 16

Thread: Help! How can you close or minimize any windows containing "Internet Explorer"

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195

    Help! How can you close or minimize any windows containing "Internet Explorer"

    anyone know?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    *bump*

  3. #3
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482

    Re: Help! How can you close or minimize any windows containing "Internet Explorer"

    Originally posted by qpabani
    anyone know?
    is this window in u'r application?
    Or is it any external window apart from u'r application?
    anita
    Can't imagine life without VB
    (Various Boyfriends)

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    the windows are outside my program..

    im sure there was some code that would close or minimize programs based on its text..

  5. #5
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    yes, you can use the sendmessage api to change the windowstate...
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    does anyone have the code?

  7. #7
    Armbruster
    Guest

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    is it possible to do that without timers? that is, when a command button is click, it closes (or minimizes - depending on the button clicked) all windows if their title contains certain text?

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    is it possible to do that without timers? that is, when a command button is click, it closes (or minimizes - depending on the button clicked) all windows if their title contains certain text?

  10. #10
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    In a Module
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    4. Private Declare Function CloseWindow Lib "user32" (ByVal hWnd As Long) As Long
    5. Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    6.  
    7. Public Sub MinimizeAllIE()
    8.     Call EnumWindows(AddressOf EnumWindowProc, 0)
    9. End Sub
    10.  
    11. Private Function EnumWindowProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
    12.     Dim sBuffer As String
    13.    
    14.     sBuffer = Space(256)
    15.     sBuffer = Left(sBuffer, GetClassName(hWnd, ByVal sBuffer, 256))
    16.     If InStr(LCase(sBuffer), "ieframe") > 0 Then
    17.         Call CloseWindow(hWnd)
    18.     End If
    19.     EnumWindowProc = hWnd
    20. End Function
    In a Form
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     MinimizeAllIE
    5. End Sub
    You can alter the code to check the Windows "Caption" if you want to just target Windows with certain text in the Caption.

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    how about other programs?

    is there no way to close all windows with a certain text in their title?

  12. #12
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You know the best way to learn is to Try some things:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    4. Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
    5. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    6.  
    7. Public Sub MinimizeAllIE()
    8.     Call EnumWindows(AddressOf EnumWindowProc, 0)
    9. End Sub
    10.  
    11. Private Function EnumWindowProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    12.     Dim sBuffer As String
    13.    
    14.     sBuffer = Space(256)
    15.     sBuffer = Left(sBuffer, GetWindowText(hwnd, ByVal sBuffer, 256))
    16.     If InStr(LCase(sBuffer), "internet explorer") > 0 Then
    17.         Call CloseWindow(hwnd)
    18.     End If
    19.     EnumWindowProc = hwnd
    20. End Function

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    so far so good.. i get the hwnds of all the IE windows, however it wont close em..

    call closewindow hwnd does nothing.. the window still exists

    anyone know how to close this window?

  14. #14
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    : I Know this is quite an old thread but:

    I get the following error

    ---------------------------
    Microsoft Visual Basic
    ---------------------------
    Compile error:

    Invalid use of AddressOf operator
    ---------------------------
    OK Help
    ---------------------------
    when i come to this with my code
    VB Code:
    1. Public Sub MinimizeAllIE()
    2.     Call EnumWindows(AddressOf EnumWindowProc, 0)
    3. End Sub

    I dont know Y Tho, i added the code above, and it dont work or dat....
    Wayne

  15. #15
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Is the code in a module?


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  16. #16
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    yeah, it was... & I tried it in the form too [just in case] and it's the same error.
    Wayne

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