title: MacOSX: get foremost window title
body: <p>I am using this code to get the window title:</p>
  
  <pre><code>tell application "System Events"
      set frontApp to name of first application process whose frontmost is true
  end tell
  
  tell application frontApp
      set window_name to name of front window
  end tell
  </code></pre>
  
  <p>However, this fails in some cases. Obviously it fails when there is no open window but that is Ok. However, in some cases, for example for <a href="http://www.xm1math.net/texmaker/" rel="noreferrer">Texmaker</a>, it fails with an error. It also doesn't work for Preview.</p>
  
  <p>What would be a way to get the window title anyway, even for cases like Texmaker?</p>