title: Powershell script presses F11 even if it's already in fullscreen
body: <p>My script is almost done. It opens IE and switches between the tabs. Half of the time it works and it also goes into fullscreen mode. The problem is, if I execute it a second time, it is already set as fullscreen but it executes F11 so it stops fullscreen mode. </p>
  
  <pre><code>[void][System.Reflection.Assembly]::LoadWithPartialName( 
  "Microsoft.VisualBasic")
  
  add-type -AssemblyName System.Windows.Forms     
  $ie = New-Object -ComObject "InternetExplorer.Application"  
  $ie.Navigate("http://www.microsoft.com")
  $ie.Navigate2("http://www.google.com" , 2048)
  $ie.Navigate2("http://www.outlook.com" , 2048)
  $ie.Navigate2("https://studer-ksg.intranet.koerber.de/de/nc/fritz-studer-ag.html" , 2048)
  $ie.Visible = $true
  
  start-sleep -Milliseconds 1000
  $IEProcess = Get-Process | Where { $_.MainWindowHandle -eq $ie.HWND }
  [Microsoft.VisualBasic.Interaction]::AppActivate($IEProcess.Id)
  
  if($ie.fullscreen){
  
  }else{
      start-sleep -Milliseconds 1000
      [System.Windows.Forms.SendKeys]::SendWait('{F11}')
  }
  do
  {
      start-sleep -Milliseconds 4000
      [System.Windows.Forms.SendKeys]::SendWait('^{TAB}')
      start-sleep -Milliseconds 100
      [System.Windows.Forms.SendKeys]::SendWait("{F5}")
  }
  While ($i -ne 0)
  </code></pre>
  
  <p>How do I make an if to make it only press F11 if it isn't already in fullscreen when I start the script?</p>
  
  <p>Thank you in advance</p>