2
votes

I have written a HTA for some task to be done. I have used CSS within it. The issue is that the page is a bit distorted (layout is not proper, buttons are misplaced), and requires a refresh/reload to have it in proper format. Hence I wanted a workaround to have the HTA to reload just ONCE after opening.

I tried writing various codes in Window_onLoad to reload the window, but it causes the window to reload infinitely (since after every reload Window_onLoad gets fired). Hence required something which could reload just once and automatically, that too as soon as window is loaded, since I don't want to keep the users waiting to have a proper view of application.

Below is the code :

body
{
	 
	margin:          0;
	padding:         0;
	background-color: #000;
	font-family:     'lucida grande', arial, tahoma, sans-serif;
}

#container
{
	margin:          0 auto;
	padding-top:0;
	width:           100%;
	position:        static;
	background-color:  #222;
}

#header
{
	margin:          0 auto;
	width:           100%;
	height:          800px;
	background:      transparent url('p1.jpg');
	background-size: 50% 50%; 
	
}

.headtitle
{
	position:        relative;
	font-family:     Times;
	font-size:       40px;
	color:           #FFF;
	top:             20px;
	left:            18px;
}

 

form {
  padding: 	20px 0;
  position: relative;
  top:      80px;
  margin: 0 auto 10px 300px; 
}

form input {
outline: 0;
  border: 0px 
  background-color: rgba(255, 255, 255, 0.2);
  width: 200px;
  border-radius: 15px;
  padding: 1px 15px;
  margin: 0 auto 10px auto;
  display: block;
  text-align: center;
  font-size: 18px;
  color: black;
  -webkit-transition-duration: 0.25s;
          transition-duration: 0.25s;
	behavior: url(PIE.htc);
  font-size: 90%;
  
  }
  
  form input:hover {
  background-color: rgba(255, 255, 255, 0.4);
}
form input:focus {
  background-color: white;
  width: 300px;
  color: #53e3a6;
}
  
 
<html>
<head>
 <HTA:APPLICATION
   APPLICATIONNAME="Simple HTA"
   BORDER="NONE"
   MaximizeButton="no"
   Scroll="NO"
   SYSMENU="YES">
   
 <title>PrOtOtYpE</title>
 <link rel="stylesheet" type="text/css" href="style.css" />
 <script language="VBScript">

	SUB RunFile 
		SET WshShell = CreateObject("WScript.Shell")
		WshShell.Run "Z:/SSH/SshClient.exe"
	End SUB
	
	SUB CloseWindow
		self.close
	End SUB

	
	SUB Window_onLoad
        window.resizeTo 800,700
	End SUB 

 </script>
  
</head>
 
<body>
 <div id="container"> 

  <div id="header">
    <div class="headtitle">PrOtOtYpE</div>
   	
	<form class="form" name="form">
			<input type="button" name="button" value="App Web Server 505" onclick="RunFile"/> 
			<input type="button" name="but" value="App Web Server 506" onclick="RunFile"/> 
			<input type="button" name="but" value="DB Server 178" onclick="RunFile"/> 
			<input type="button" name="but" value="DB  Server 177" onclick="RunFile"/> 
			<input type="button" name="but" value="Close" onclick="CloseWindow"/> 
	</form>
			
</div>
</div>
 </body>
 </html>
 
 
1
Why don't you try to fix the issues with the layout instead of finding a workaround?Teemu
The Problem started off after using PIE.htc (for rounded corners). Before it, the HTA loaded properly. Cannot think of any solution.Prateek Jaiswal
Not using PIE.htc comes to mind ...Ansgar Wiechers
@PrateekJaiswal Please read stackoverflow.com/a/19570684/1169519 , you can use for example IE9 mode to get rounded corners.Teemu
Ideally we need to see your HTA code to advise better.user692942

1 Answers

0
votes

In onload set a flag.

'Making a public variable
Dim FirstRunFlag

SUB Window_onLoad
        window.resizeTo 800,700
        If FirstRunFlag=0 then 
                window.refresh
                FirstRunFlag=1
       End If
End SUB 

or make this the first script run in the head before the style sheets.

<html>
<head>
<script language=vbscript>

    window.resizeTo 800,700
</script>
<style>
etc etcetc
</style>
</head>
<body>ra, ra, ra.</body>
</html>