<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>North Atlanta Web Design &#187; HTML Applications</title>
	<atom:link href="https://www.northatlantawebdesign.com/index.php/category/html-applications/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.northatlantawebdesign.com</link>
	<description>Programming Examples, Samples, and Tutorials</description>
	<lastBuildDate>Mon, 15 Aug 2011 20:18:35 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.7.41</generator>
	<item>
		<title>HTA Progress Bar using VBScript and JavaScript</title>
		<link>https://www.northatlantawebdesign.com/index.php/2009/07/17/hta-progress-bar-using-vbscript-and-javascript/</link>
		<comments>https://www.northatlantawebdesign.com/index.php/2009/07/17/hta-progress-bar-using-vbscript-and-javascript/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 17:53:30 +0000</pubDate>
		<dc:creator><![CDATA[Jeff Gibeau]]></dc:creator>
				<category><![CDATA[HTML Applications]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[HTA]]></category>
		<category><![CDATA[Progress Bar]]></category>
		<category><![CDATA[Progressbar]]></category>
		<category><![CDATA[VBScript Front End]]></category>
		<category><![CDATA[VBScript GUI]]></category>

		<guid isPermaLink="false">http://www.northatlantawebdesign.com/?p=88</guid>
		<description><![CDATA[I was informed after my last post that using HTA (HTML Applications) to display a progress bar in VBScript is much more efficient than using InternetExplorer.Application within a VBScript. Having never used HTA before, I immediately set out to learn a bit and see what I could come up with. My initial thoughts are mixed, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I was informed after my <a href="http://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/">last post</a> that using <a type="amzn">HTA</a> (HTML Applications) to display a progress bar in <a type="amzn">VBScript</a> is much more efficient than using InternetExplorer.Application within a VBScript.  Having never used HTA before, I immediately set out to learn a bit and see what I could come up with.</p>
<p>My initial thoughts are mixed, as <strong>you can not run and interact with an HTA from a VBScript file</strong>.  This requires you to wrap your VBScript code in whatever HTML Application you are writing.  This greatly limits re-usability, enough so that the increase in performance may not warrant using an HTA for a progress bar in most cases.<br />
<span id="more-88"></span><br />
I would like to note that this is a first draft of this script, and I may update it in the future, if I deem HTML Applications the way to go.  As for now, I am not convinced.</p>
<pre class="brush: vb; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;HTA Progress Bar&lt;/title&gt;
&lt;script language=&quot;vbscript&quot;&gt;
'This script resizes and moves the window to the center of the screen.
'The placement of this code above the HTA definition, moves the window
'before the script is visible. 
height = screen.height
width = screen.width
moveto width/2 - 335/2,height/2 - 200/2
resizeto 335,200
&lt;/script&gt;
	&lt;HTA:APPLICATION ID=&quot;oMyApp&quot;
		APPLICATIONNAME=&quot;monster&quot;
		SINGLEINSTANCE=&quot;yes&quot;
		BORDER=&quot;thin&quot;
		MAXIMIZEBUTTON=&quot;no&quot;
&gt;

&lt;script language=&quot;VBScript&quot; type=&quot;text/vbscript&quot;&gt;
'This is where your VBScript logic should go.
' Call OpenProgressBar to open the progressbar
' Call UpdateLog to update the logging window
' Call UpdateProgressBar to move the bar
' Call CloseProgressBar to return to your main UI window
Sub BeginImportingFiles()
	Dim i
	OpenProgressBar()
	UpdateLog &quot;Step 1 of 2&quot;, &quot;&quot;
	For i = 1 to 10
		Sleep 100
		UpdateLog &quot;Next Step&quot;, &quot;&quot; &amp; Time()
		UpdateProgressBar i*10, &quot;Step 1 of 2&quot;
	Next
	UpdateLog &quot;Step 1 of 2&quot;, &quot;Complete&quot;
	Sleep 2000
	CloseProgressBar()
End Sub

Sub Sleep(MSecs) 
	Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
	If Fso.FileExists(&quot;sleeper.vbs&quot;)=False Then
	Set objOutputFile = fso.CreateTextFile(&quot;sleeper.vbs&quot;, True)
	objOutputFile.Write &quot;wscript.sleep WScript.Arguments(0)&quot;
	objOutputFile.Close
	End If
	CreateObject(&quot;WScript.Shell&quot;).Run &quot;sleeper.vbs &quot; &amp; MSecs,1 , True
End Sub

&lt;/script&gt;
&lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;
function OpenProgressBar()
{
	document.getElementById(&quot;gui&quot;).style.display=&quot;none&quot;;
	document.getElementById(&quot;progressbargui&quot;).style.display=&quot;block&quot;;
}

function UpdateLog(text, status)
{
	var log = document.getElementById(&quot;log&quot;);
	if(status &amp;&amp; status != &quot;&quot;)
	{
		var maxLength = 33;
		var dotlength = maxLength - (text.length + status.length);
		var dots = &quot;&quot;;
		for(i = 0;i&lt;dotlength;i++)
			dots += &quot;.&quot;;
		log.value += text + dots + &quot;[&quot; + status + &quot;]\n&quot;;
	}
	else
		log.value += &quot;[&quot; + text + &quot;]&quot; + &quot;\n&quot;;
	log.scrollTop = log.scrollHeight;
}

function UpdateProgressBar(percentComplete, title, status)
{
	for(i = 1; i &lt;= 100; i++)
	{
		if((percentComplete) &gt;= i)
			document.getElementById(&quot;pbar&quot;+i).className = &quot;pbarcomplete&quot;;
		else
			document.getElementById(&quot;pbar&quot;+i).className = &quot;pbar&quot;;
		document.title = title &amp;&amp; title != &quot;&quot; ? title : percentComplete + &quot;% Complete&quot;;
		document.getElementById(&quot;progresstitle&quot;).innerText = status &amp;&amp; status != &quot;&quot; ? status : percentComplete + &quot;% Complete&quot;;
	}
}

function CloseProgressBar()
{
	document.getElementById(&quot;gui&quot;).style.display=&quot;block&quot;;
	document.getElementById(&quot;progressbargui&quot;).style.display=&quot;none&quot;;
	UpdateProgressBar(0,&quot;&quot;,&quot;&quot;);
	document.getElementById(&quot;log&quot;).value = &quot;&quot;;
}
&lt;/script&gt;
&lt;script language=&quot;VBScript&quot; type=&quot;text/vbscript&quot;&gt;
'Progress Bar Logic
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
body,html {
	margin:auto;
}
div#progressbar{
border:1px solid #ccc;
margin:0px;padding:0px;
}
span.pbar{
	width:3px;
	margin:0px;
	padding:0px;
	border-left:1px solid #fff;
	background:#fff;
	line-height:5px;
	height:16px;
	font-size:2px;
}
span.pbarcomplete{
	width:3px;
	margin:0px;
	padding:0px;
	border-right:1px solid #ccc;
	background:green;
	line-height:5px;
	height:16px;
	font-size:2px;
	
}
table {
	width:100%;
	height:100%;
}
table td {
	text-align:center;
	vertical-align:center;
}
table td.progressbargui {
	display:none;
	vertical-align:top;
}
textarea#log{
	width:100%;
	height:100px;
	border:1px solid #aaa;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
	&lt;td id=&quot;gui&quot;&gt;&lt;input type=&quot;button&quot; onclick=&quot;BeginImportingFiles()&quot; value=&quot;Begin File Import&quot;/&gt;&lt;/td&gt;
	&lt;td id=&quot;progressbargui&quot; class=&quot;progressbargui&quot;&gt;
		&lt;div id=&quot;progresstitle&quot;&gt;&amp;nbsp;&lt;/div&gt;
		&lt;div id=&quot;progressbar&quot;&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
		for(i = 1; i &lt;= 100; i++)
			document.write(&quot;&lt;span id=\&quot;pbar&quot; + i + &quot;\&quot; class=\&quot;pbar\&quot;&gt;&lt;/span&gt;&quot;);
		&lt;/script&gt;
		&lt;/div&gt;
		&lt;textarea id=&quot;log&quot;&gt;&lt;/textarea&gt;
	&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;/body&gt;
&lt;/html&gt;

</pre>
<p>Some potentially useful links dealing with HTA:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx" target="_blank">HTML Applications Introduction</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms536473%28VS.85%29.aspx" target="_blank">HTA Reference</a></li>
<li><a href="http://www.amazon.com/gp/product/0735622442?ie=UTF8&#038;tag=cheesymovieni-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0735622442" target="_blank">Advanced VBScript for Microsoft  Windows  Administrators (Book)</a><img src="http://www.assoc-amazon.com/e/ir?t=cheesymovieni-20&#038;l=as2&#038;o=1&#038;a=0735622442" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.northatlantawebdesign.com/index.php/2009/07/17/hta-progress-bar-using-vbscript-and-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
