Centring a hta window

Using WMI for this is a bit overkilling. You can use screen object instead:

window.resizeTo (800, 600);
window.moveTo((screen.width - 800) / 2, (screen.height - 600) / 2);

If you want to resize the window at start, put the lines above to a (JS) script tag in the head section, even before <hta: application> tag, or use the code in an event handler or where ever you need it.

If you want to exclude taskbar's height out of the centering area, you can use screen.availHeight instead of screen.height.


var winWidth = 800, winHeight = 600;
window.resizeTo(winWidth, winHeight);
window.moveTo((screen.width - winWidth) / 2, (screen.height - winHeight) / 2);

Tags:

Html

Hta