How to use "window.KeyboardMaestro.ResizeWindow"

Hi, the wiki page says we can use "window.KeyboardMaestro.ResizeWindow( “1,2,3,4” )" to resize the window:

resize the window to the specified size or frame as a string with commas (“width,height” or “left,top,width,height”)

I can't get it to work.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>Test Window Resize</title>
	<style type="text/css">
	</style> 
</head>
<body>
	<div>
		<h1 style="text-align: center; vertical-align: middle;">Test Window Resize</h1>
	</div>
<script>
window.KeyboardMaestro.ResizeWindow( "1290,690" );
</script>
</body>
</html>

I've also tried to put it into the "KMInit()" function. Does not work either.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>Test Window Resize</title>
	<style type="text/css">
	</style> 
</head>
<body>

	<div>
		<h1 style="text-align: center; vertical-align: middle;">Test Window Resize</h1>
	</div>

<script>
function KMInit() {
	window.KeyboardMaestro.ResizeWindow( "1290,690" );
}
</script>
</body>
</html>

Any help appreciated!

Try this approach:

<DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>Test Window Resize</title>
	<style type="text/css">
	</style> 
</head>
<body>
	<div>
		<h1 style="text-align: center; vertical-align: middle;">Test Window Resize</h1>
	</div>
	<button class="button" name="Resize" type="submit" onclick="window.KeyboardMaestro.ResizeWindow( '0,0,500,281' )">Resize</button></p>
</body>
</html>

If you just want to set the window size, try this:

<body data-kmwindow="SCREENVISIBLE(Main,MidX)-250,SCREEN(Main,Top,20%),500,281" >
1 Like

Hi @mrpasini,

Thank you very much!
Your post let me see that the window resize function may be triggered by an external trigger, such as a click of the resize button.

Inspired by your post, I added a "keydown" event listener function and use KM to simulate keystroke to trigger it. This meets all my needs. The HTML prompt window will resize immediately after opening.

Thanks a lot!!!

Glad to help!