title: Can't get Window 1 of process intermittently thrown
body: <p>I have an applescript saved as an always on application, which generally works. However, there are odd instances where it will throw the error:
  <em>"Systems Events got an error: Can't get window 1 of process "FaceTime". Invalid index. (-1719)"</em>
  Mostly occurs if FaceTime app is closed, but not always. Odd. </p>
  
  <p>Can anyone advise how I can dismiss this or write better code to avoid?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>on idle
  if application "FaceTime" is running then
      tell application "System Events"
          tell process "FaceTime"
              if get value of attribute "axFullScreen" of window 1 = false then
                  set FullscreenButton to a reference to (button "Full Screen" of window 1)
                  if FullscreenButton exists then
                      click FullscreenButton
                  end if
              end if
          end tell
  
      end tell
  end if
  return 3
  </code></pre>
  
  <p>end idle</p>
  
  <p>on quit
      continue quit
  end quit</p>