|
-
Jun 22nd, 2005, 02:53 PM
#1
Thread Starter
Hyperactive Member
IF IE explorer window "google" exists then... {RESOLVED}
Hello,
I am using this code to maximize a IE window.
In a module:
VB Code:
Option Explicit
Private g_TheCollWin As Collection
Private Const SW_MAXIMIZE As Long = 3
Private Declare Function EnumWindows Lib "user32.dll" ( _
ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Boolean
Private Declare Function ShowWindow Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" ( _
ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" ( _
ByVal hwnd As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SetForegroundWindow Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Public Sub Maxamize_Process(ByVal strWindowTitle As String)
Set g_TheCollWin = New Collection
g_TheCollWin.Add strWindowTitle
Call EnumWindows(AddressOf EnumWindowsProc, ByVal 0&)
End Sub
Private Function EnumWindowsProc(ByVal lngHwnd As Long, ByVal lngParam As Long) As Boolean
Dim strSave As String
Dim lngRet As Long
Dim varTheItem As Variant
lngRet = GetWindowTextLength(lngHwnd)
If lngRet > 0 Then
strSave = Space$(lngRet)
Call GetWindowText(lngHwnd, strSave, lngRet + 1)
For Each varTheItem In g_TheCollWin
If InStr(1, strSave, varTheItem, vbTextCompare) > 0 And InStr(1, strSave, "Google.com", vbTextCompare) > 0 Then
Call SetForegroundWindow(lngHwnd)
Call ShowWindow(lngHwnd, SW_MAXIMIZE)
End If
Next
End If
EnumWindowsProc = True
End Function
AND in a cmd button:
VB Code:
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.
-
Jun 22nd, 2005, 03:06 PM
#2
Re: IF IE explorer window "google" exists then...
VB Code:
Option Explicit
Dim tWnd As Long
Dim frmname As String
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
frmname = "Google - Microsoft Internet Explorer"
tWnd = FindWindow(vbNullString, frmname)
If tWnd <> 0 Then
MsgBox "Googles open"
Else
MsgBox "Open google"
End If
End Sub
-
Jun 22nd, 2005, 03:31 PM
#3
Thread Starter
Hyperactive Member
Re: IF IE explorer window "google" exists then...
Thanks man! That should do it!
Stilekid007
P.S. I rated you!
-
Jun 22nd, 2005, 03:32 PM
#4
Re: IF IE explorer window "google" exists then...
thanks bud ; )
p.s ie's classname is IEFrame if you need it
-
Jun 22nd, 2005, 03:33 PM
#5
Thread Starter
Hyperactive Member
Re: IF IE explorer window "google" exists then...
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
|