Search code examples
javascriptvbscriptpositionhta

HTA application: Place window at the bottom-right of the screen


I'm trying to move my hta application window to the bottom-right of my desktop (screen). If I put static values, then It works but I want to place the window at the bottom-right for every screen resolution. I don't know how to say to the .hta "place the window 50% from the top border and 5% from the right border". Here's my little script:

<script language="VBScript">
   'On Error Resume Next
   window.resizeTo 450, 400
   var monitorHeight = screen.Height;
   var monitorWidth = screen.Width; 

    window.moveTo monitorWidth-450, monitorHeight-400



    window.moveTo WindowLeft,WindowTop 

</script>

I can center the window:

<script language="VBScript">
  'On Error Resume Next   
  window.resizeTo 450, 400
window.moveTo (screen.width -450) / 2, (screen.height-400) / 2
</script>

But can't put the window at the bottom-right.


Solution

  • You can try something like that :

    <script language="VBScript">
        window.resizeTo 450,400
        WindowLeft = (window.screen.availWidth - 450)  
        WindowTop  = (window.screen.availHeight - 400)
        window.moveTo WindowLeft, WindowTop
    </script>