Results 1 to 3 of 3

Thread: close it!, or something like it.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    183

    Talking

    Hi all,
    I'm trying to create a program similar to close it!, whenever a popup window opens it compare the text and address with a list of text, if any of the text is the same in both lists then it closes the window.
    I've gotten together most of the stuff but I can't figure out how to get ahold of the text of the popup, or the text of the address.
    Anyone know how to get access to these?

  2. #2
    Guest
    Use FindWindow. The following example will close Calculator as soon as it opens. Just change the name to whatever App you want to close.
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Const WM_CLOSE = &H10
    Const WM_CHAR = &H102
    Const WM_KEYDOWN = &H100
    
    Private Sub Timer1_Timer()
        Dim PHWND As Long
        PHWND = FindWindow(vbNullString, "Calculator")
        If PHWND <> 0 Then
            SendMessage PHWND, WM_CLOSE, 0, 0
            DestroyWindow PHWND
        End If
    End Sub

  3. #3
    Guest
    If you know the caption, than use this:

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Declare Function PostMessage Lib "user32" Alias _
    "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long                    
    Public Const WM_CLOSE = &H10
    
    Private Sub Timer1_Timer()
    Dim winHwnd As Long
    Dim RetVal As Long
    winHwnd = FindWindow(vbNullString, "Caption")
    If winHwnd <> 0 Then
        RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
    Else
        Exit Sub
    End If
    End Sub

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