title: ShowWindow won't set focus or maximize
body: <p>The following code will not set focus to the IE window that I need, nor will it maximize it like it's supposed to.</p>
  
  <pre><code>Option Explicit On
  Public Class Form1
      Public Declare Auto Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
      Private Sub automateIE()
          Dim shellWindows = New SHDocVw.ShellWindowsClass()
          For Each ie As SHDocVw.InternetExplorer In shellWindows
              Dim isIE As Boolean = True
              Try
                  Dim ie2 As mshtml.IHTMLDocument = ie.Document
              Catch ex As Exception
                  isIE = False
              End Try
              If isIE Then
                  If ie.LocationURL.Contains("url") Then
                      ShowWindow(ie.HWND, 3)
                      Exit For
                  End If
              End If
          Next
      End Sub
  End Class
  </code></pre>