title: AppleScript get title of a window
body: <p>I try to get the title of an app (and copy it as a var)
  Here is my code so far but this is failing </p>
  
  <pre><code>tell application "app"
      activate
  end tell
  
  tell application "System Events"
      set frontApp to name of first application process whose frontmost is true
  end tell
  
  tell application frontApp
      if the (count of windows) is not 0 then
          set window_name to name of front window
      end if
  end tell
  </code></pre>
  
  <p>Result :</p>
  
  <blockquote>
    <p>error "app got an error: every window doesn’t understand the “count” message." number -1708 from every window</p>
  </blockquote>