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




Reply With Quote