Results 1 to 5 of 5

Thread: IF IE explorer window "google" exists then... {RESOLVED}

  1. #1

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    IF IE explorer window "google" exists then... {RESOLVED}

    Hello,

    I am using this code to maximize a IE window.

    In a module:

    VB Code:
    1. Option Explicit
    2.  
    3. Private g_TheCollWin As Collection
    4. Private Const SW_MAXIMIZE As Long = 3
    5.  
    6. Private Declare Function EnumWindows Lib "user32.dll" ( _
    7.     ByVal lpEnumFunc As Long, _
    8.     ByVal lParam As Long) As Boolean
    9.    
    10.  
    11. Private Declare Function ShowWindow Lib "user32.dll" ( _
    12.     ByVal hwnd As Long, _
    13.     ByVal nCmdShow As Long) As Long
    14.  
    15. Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" ( _
    16.     ByVal hwnd As Long, _
    17.     ByVal lpString As String, _
    18.     ByVal cch As Long) As Long
    19.  
    20. Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" ( _
    21.     ByVal hwnd As Long) As Long
    22. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    23.     ByVal hwnd As Long, _
    24.     ByVal wMsg As Long, _
    25.     ByVal wParam As Long, _
    26.     lParam As Any) As Long
    27.  
    28. Private Declare Function SetForegroundWindow Lib "user32.dll" ( _
    29.     ByVal hwnd As Long) As Long
    30.  
    31. Public Sub Maxamize_Process(ByVal strWindowTitle As String)
    32.     Set g_TheCollWin = New Collection
    33.     g_TheCollWin.Add strWindowTitle
    34.     Call EnumWindows(AddressOf EnumWindowsProc, ByVal 0&)
    35. End Sub
    36.  
    37. Private Function EnumWindowsProc(ByVal lngHwnd As Long, ByVal lngParam As Long) As Boolean
    38.     Dim strSave As String
    39.     Dim lngRet As Long
    40.     Dim varTheItem As Variant
    41.     lngRet = GetWindowTextLength(lngHwnd)
    42.     If lngRet > 0 Then
    43.         strSave = Space$(lngRet)
    44.         Call GetWindowText(lngHwnd, strSave, lngRet + 1)
    45.         For Each varTheItem In g_TheCollWin
    46.             If InStr(1, strSave, varTheItem, vbTextCompare) > 0 And InStr(1, strSave, "Google.com", vbTextCompare) > 0 Then
    47.                 Call SetForegroundWindow(lngHwnd)
    48.                 Call ShowWindow(lngHwnd, SW_MAXIMIZE)
    49.             End If
    50.         Next
    51.     End If
    52.     EnumWindowsProc = True
    53. End Function

    AND in a cmd button:


    VB Code:
    1. Maxamize_Process ("Google.com")


    Now what I need the above code to do is IF "google.com" does not exist in a window(Title) then it would give me a msgbox "Please open google"
    Else if open
    msgbox "Thank you"

    Does anyone know how to set that up?

    Thank you!
    Stilekid007
    Last edited by stilekid007; Jun 22nd, 2005 at 03:34 PM.

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: IF IE explorer window "google" exists then...

    VB Code:
    1. Option Explicit
    2. Dim tWnd As Long
    3. Dim frmname As String
    4. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    5.  
    6. Private Sub Form_Load()
    7. frmname = "Google - Microsoft Internet Explorer"
    8. tWnd = FindWindow(vbNullString, frmname)
    9.     If tWnd <> 0 Then
    10.         MsgBox "Googles open"
    11.     Else
    12.         MsgBox "Open google"
    13.     End If
    14. End Sub

  3. #3

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: IF IE explorer window "google" exists then...

    Thanks man! That should do it!
    Stilekid007
    P.S. I rated you!

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: IF IE explorer window "google" exists then...

    thanks bud ; )
    p.s ie's classname is IEFrame if you need it

  5. #5

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: IF IE explorer window "google" exists then...

    Alright Great!

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