Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Flashing message in an HTA

1,070 views
Skip to first unread message

Highlander

unread,
Feb 15, 2008, 9:33:08 AM2/15/08
to
Hello all.

I've found the following script handy for usage with an HTA:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0130.mspx

My question is...how can I cause the message displayed
("Searching ....") to flash every couple seconds while it's
processing; and then stop flashing when it's finished?

Just want to spruce up my HTA a bit. Any suggestions would be greatly
appreciated.

Thanks!

- Dave

Travis Newbury

unread,
Feb 15, 2008, 10:38:54 AM2/15/08
to
On Feb 15, 9:33 am, Highlander <tron9...@msn.com> wrote:
> Just want to spruce up my HTA a bit. Any suggestions would be greatly
> appreciated.

Use Flash. With CS3 it is a match made in heaven for applications on
the web.

Andy Dingley

unread,
Feb 15, 2008, 11:12:20 AM2/15/08
to
On 15 Feb, 14:33, Highlander <tron9...@msn.com> wrote:

> I've found the following script handy for usage with an HTA:

Firstly HTA is a red-herring. HTA's are evil and best avoided. What
you asked for literally can be done in a web-compliant fashion,
without needing that sort of necromancy. Web techniques apply to HTAs
OK, some HTA techniques are (thankfully!) forbidden for web use.

Find a good JavaScript tutorial. (M$oft isn't - they're too busy
pushing proprietary tweaks, not standards).

Study two things: How to do simple visual effects by dynamic CSS
changes, and using JavaScript's .SetTimeout() method to drive things
with intervals. The rest is just a bit of practice and legwork in
coding your scripts.

If you get stuck, try asking in comp.lang.javascript

Don't use VBScript. Don't ever use it for web work (client-side or
server-side). It's an ugly language, anything it can do, JavaScript or
JScript can do better. Mostly though, using J(ava)Script gives you
some hope of working on other browsers, client-side VBScript limits
you and your users to IE only.

Flash would be ridiculous overkill for this.


Jonathan N. Little

unread,
Feb 15, 2008, 12:17:18 PM2/15/08
to
Andy Dingley wrote:
> On 15 Feb, 14:33, Highlander <tron9...@msn.com> wrote:
>
>> I've found the following script handy for usage with an HTA:
>
> Firstly HTA is a red-herring. HTA's are evil and best avoided. What
> you asked for literally can be done in a web-compliant fashion,
> without needing that sort of necromancy. Web techniques apply to HTAs
> OK, some HTA techniques are (thankfully!) forbidden for web use.
>
> Find a good JavaScript tutorial. (M$oft isn't - they're too busy
> pushing proprietary tweaks, not standards).
>
> Study two things: How to do simple visual effects by dynamic CSS
> changes, and using JavaScript's .SetTimeout() method to drive things
> with intervals. The rest is just a bit of practice and legwork in
> coding your scripts.
>

Yes a simple image swap from an animated gif to a static one. Or you can
do it with style, IE does support blink so you could toggle color with
setInterval...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-language" content="en-us">
<title>Text Only</title>

<style type="text/css">
#blinker{ color: #88f; text-decoration: blink; }
</style>

<script type="text/javascript">

function done(){
var el=document.getElementById('blinker');

// IE has problems with setAttribute on 'style'
// el.setAttribute('style','color: #f00; text-decoration: none;');
// set directly
el.style.color='#f00';
el.style.textDecoration='none';

el.firstChild.nodeValue="Done!";
}

function countdown(){
var t=setTimeout("done()",10000); //10 seconds
}

// attach event after page loads
if( window.addEventListener ) {
window.addEventListener('load',countdown,false); //legacy
} else if( document.addEventListener ) {
document.addEventListener('load',countdown,false); //proper
} else if( window.attachEvent ) {
window.attachEvent("onload", countdown); //IE only
}
</script>

</head>
<body>
<p>
Simple example of a blinker.
<span id="blinker">Working...</span>
</p>
</body>
</html>

> If you get stuck, try asking in comp.lang.javascript
>
> Don't use VBScript. Don't ever use it for web work (client-side or
> server-side). It's an ugly language, anything it can do, JavaScript or
> JScript can do better. Mostly though, using J(ava)Script gives you
> some hope of working on other browsers, client-side VBScript limits
> you and your users to IE only.
>
> Flash would be ridiculous overkill for this.

For Travis all roads lead to flash.


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Highlander

unread,
Feb 15, 2008, 12:37:21 PM2/15/08
to
> LITTLE WORKS STUDIOhttp://www.LittleWorksStudio.com- Hide quoted text -
>
> - Show quoted text -

Thanks for all the responses.

I was hoping there was something simple like:

<blink>flashing text here</blink>

But this doesn't work. I believe it's an issue with the BLINK element
not working in IE 6.

Thanks for the code Jonathan, but it doesn't work on my machine. Plus,
that amount of code is overkill for simply wanting to make some text
flash. I think I'll shelf this idea.

Thanks again.

- Dave

Andy Dingley

unread,
Feb 15, 2008, 12:43:02 PM2/15/08
to
On 15 Feb, 17:37, Highlander <tron9...@msn.com> wrote:

> But this doesn't work. I believe it's an issue with the BLINK element
> not working in IE 6.

The code to do blinking is pretty simple.

It's just that people who think this is a good idea find it hard to
type, after c.i.w.a.h have got to them and broken their fingers.

Tom K

unread,
Feb 15, 2008, 3:11:24 PM2/15/08
to
My, Andy sure does feel strongly about this, as do many when it comes to
blink. For my use blinking was utilitarian and not fluff.

I accomplished the blinking text in VBScript with the code below. The big
problem I encountered is that wscript.sleep doesn't work in an HTA, so I
used the the PING command with -n option. You can roughly say one second
for each -n.

The code below will blink the words until notepad is closed.

Set oExec = oShell.Exec("notepad.exe")
i = 1
Do While oExec.Status = 0
idMsgArea.InnerHTML = "Words to blink"
oShell.Run "ping.exe -n 2 127.0.0.1", 0, True
i = i + 1
loop

Tom K.


MikeB

unread,
Feb 15, 2008, 7:22:11 PM2/15/08
to

"Tom K" <thomas....@ThighmarkDOT.com> wrote in message
news:%23UGqx7A...@TK2MSFTNGP04.phx.gbl...

> My, Andy sure does feel strongly about this, as do many when it comes to
> blink. For my use blinking was utilitarian and not fluff.
>
> I accomplished the blinking text in VBScript with the code below. The big
> problem I encountered is that wscript.sleep doesn't work in an HTA, so I

But setTimeOut does... In HTAs you can call VBScript and J(ava)Script
interactively. If it's quick and dirty I tend to use VBScript. If there's
much heavy lifting involved, J(ava)Script.

MikeB

unread,
Feb 15, 2008, 7:24:07 PM2/15/08
to

"Highlander" <tron...@msn.com> wrote in message
news:44fe76be-0c7a-484b...@s8g2000prg.googlegroups.com...

>

Thanks again.

- Dave
>

Don't cave so fast. After you do it once, you will have it for posterity..

Blinky the Shark

unread,
Feb 15, 2008, 7:37:09 PM2/15/08
to
MikeB wrote:

> I was hoping there was something simple like:
>
> <blink>flashing text here</blink>

Hey, I'll do the blinking around here.

--
Blinky
Killing all posts from Google Groups
The Usenet Improvement Project: http://improve-usenet.org
Blinky: http://blinkynet.net

dorayme

unread,
Feb 15, 2008, 7:44:09 PM2/15/08
to
In article <#Y6S$IDcIH...@TK2MSFTNGP04.phx.gbl>,
"MikeB" <m.byerleyATVerizonDottieNettie> wrote:

>
> "Highlander" <tron...@msn.com> wrote in message
> news:44fe76be-0c7a-484b...@s8g2000prg.googlegroups.com...
> On Feb 15, 11:17 am, "Jonathan N. Little" <lws4...@central.net> wrote:
>
> >
>
> Thanks for all the responses.
>
> I was hoping there was something simple like:
>
> <blink>flashing text here</blink>
>
> But this doesn't work. I believe it's an issue with the BLINK element
> not working in IE 6.
>
> Thanks for the code Jonathan, but it doesn't work on my machine. Plus,
> that amount of code is overkill for simply wanting to make some text
> flash. I think I'll shelf this idea.
>

What about a small animated gif? Think about its natural
advantages: for little code, it flashes and annoys, it does not
resize and it is a bit of a bother to implement. <g>

--
dorayme

Travis Newbury

unread,
Feb 15, 2008, 8:36:17 PM2/15/08
to
On Feb 15, 7:44 pm, dorayme <doraymeRidT...@optusnet.com.au> wrote:
> In article <#Y6S$IDcIHA....@TK2MSFTNGP04.phx.gbl>,

> > <blink>flashing text here</blink>
> What about a small animated gif? Think about its natural
> advantages: for little code, it flashes and annoys, it does not
> resize and it is a bit of a bother to implement. <g>

Or Flash!

MikeB

unread,
Feb 15, 2008, 8:37:34 PM2/15/08
to

"MikeB" <m.byerleyATVerizonDottieNettie> wrote in message
news:%23Y6S$IDcIH...@TK2MSFTNGP04.phx.gbl...


<html>
<HEAD>
<TITLE>This is the Application Caption</TITLE>
<HTA:APPLICATION ID="oApp"
APPLICATIONNAME="Splash Screen"
BORDER="thick"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
CAPTION="YES"
ICON=""
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal">
<style type="text/css">
.textBlack {
color : #000000;
}
.textRed {
color : #CC0000;
}

</style>

<SCRIPT type="text/javascript">
var bBlinkON = false;

function SwapColors(valIN)
{
if (valIN.className=='textBlack')
valIN.className='textRed';
else
valIN.className='textBlack';
return;
}

function Init()
{
var fSC = function (){
SwapColors(window.document.getElementById('spanToBlink'))};
var UpdateTime = window.setInterval(fSC,1000);
}
function Terminate()
{
window.clearTimeout();
}

</SCRIPT>
</HEAD>

<body onload="Init(); return false;">

<div><span id="spanToBlink" class="textBlack">This is my blinking Text!</span>


</div>

</body>

</html>


dorayme

unread,
Feb 15, 2008, 8:54:46 PM2/15/08
to
In article
<b8709f28-0081-4665...@e6g2000prf.googlegroups.com
>,
Travis Newbury <Travis...@hotmail.com> wrote:

Ha! Got you to admit the disadvantages! I knew this would flush
you out and trap you finally, you slippery old dog.

--
dorayme

mayayana

unread,
Feb 15, 2008, 9:29:09 PM2/15/08
to
I don't know if this is the best option, but what
about a simple animated GIF with some frames
text and some frames blank? Then you could just
show the GIF or hide it.

Paint Shop Pro has an Animation Shop that can
do that fairly simply. I expect there are also other
programs available.

And yes, BLINK is a Netscape tag that's almost
never used because, like MARQUEE, it's irritating.

You might also try limiting the groups you post
to next time. You've set off a barage of inflammatory
wiseacreing by mentioning HTAs in a non-VBS group. :)

Jonathan N. Little

unread,
Feb 15, 2008, 9:42:37 PM2/15/08
to
MikeB wrote:
> "MikeB" <m.byerleyATVerizonDottieNettie> wrote in message
> news:%23Y6S$IDcIH...@TK2MSFTNGP04.phx.gbl...
>> "Highlander" <tron...@msn.com> wrote in message
>> news:44fe76be-0c7a-484b...@s8g2000prg.googlegroups.com...
>> On Feb 15, 11:17 am, "Jonathan N. Little" <lws4...@central.net> wrote:
>>
>
>> Don't cave so fast. After you do it once, you will have it for posterity..
>
>
> <html>
> <HEAD>
> <TITLE>This is the Application Caption</TITLE>
> <HTA:APPLICATION ID="oApp"
> APPLICATIONNAME="Splash Screen"
> BORDER="thick"
> MAXIMIZEBUTTON="yes"
> MINIMIZEBUTTON="yes"
> CAPTION="YES"
> ICON=""
> SHOWINTASKBAR="yes"
> SINGLEINSTANCE="yes"
> SYSMENU="yes"
> WINDOWSTATE="normal">
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Did you insert this for some purpose? Not required for JavaScript to
work on IE...

dorayme

unread,
Feb 15, 2008, 10:24:44 PM2/15/08
to
In article <uBudKPEc...@TK2MSFTNGP04.phx.gbl>,
"mayayana" <mayaXX...@mindXXspring.com> wrote:

> And yes, BLINK is a Netscape tag that's almost
> never used because, like MARQUEE, it's irritating.

Did you say Marquee? Interested in car races?

--
dorayme

MikeB

unread,
Feb 15, 2008, 11:33:52 PM2/15/08
to

"Jonathan N. Little" <lws...@central.net> wrote in message
news:59103$47b64d9c$40cba7a8$26...@NAXS.COM...

> MikeB wrote:
>> "MikeB" <m.byerleyATVerizonDottieNettie> wrote in message
>> news:%23Y6S$IDcIH...@TK2MSFTNGP04.phx.gbl...
>>> "Highlander" <tron...@msn.com> wrote in message
>>> news:44fe76be-0c7a-484b...@s8g2000prg.googlegroups.com...
>>> On Feb 15, 11:17 am, "Jonathan N. Little" <lws4...@central.net> wrote:
>>>
>>
>>> Don't cave so fast. After you do it once, you will have it for posterity..
>>
>>
>> <html>
>> <HEAD>
>> <TITLE>This is the Application Caption</TITLE>
>> <HTA:APPLICATION ID="oApp"
>> APPLICATIONNAME="Splash Screen"
>> BORDER="thick"
>> MAXIMIZEBUTTON="yes"
>> MINIMIZEBUTTON="yes"
>> CAPTION="YES"
>> ICON=""
>> SHOWINTASKBAR="yes"
>> SINGLEINSTANCE="yes"
>> SYSMENU="yes"
>> WINDOWSTATE="normal">
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Did you insert this for some purpose? Not required for JavaScript to work on
> IE...
>
It's not for IE.. HTA's are hosted by mshta.exe, not iexplorer.exe. It's
just some standard nomenclature inthe HTA tag. It will work perfectly without
any of it.

Travis Newbury

unread,
Feb 16, 2008, 8:41:20 AM2/16/08
to
On Feb 15, 8:54 pm, dorayme <doraymeRidT...@optusnet.com.au> wrote:
> > Or Flash!
> Ha! Got you to admit the disadvantages! I knew this would flush
> you out and trap you finally, you slippery old dog.

You failed to read the thread, I sad Flash a long long time ago....

Neredbojias

unread,
Feb 16, 2008, 12:57:11 PM2/16/08
to
Well bust mah britches and call me cheeky, on Sat, 16 Feb 2008 13:41:20 GMT
Travis Newbury scribed:

One wouldn't really have to read the thread to figure that...

--
Neredbojias
Riches are their own reward.

dorayme

unread,
Feb 16, 2008, 3:43:56 PM2/16/08
to
In article
<1cc21432-7a81-4cae...@28g2000hsw.googlegroups.com

>,
Travis Newbury <Travis...@hotmail.com> wrote:

You mean that earlier on you admitted that Flash was (to quote
the words your reply was to) "for little code, it flashes and

annoys, it does not resize and it is a bit of a bother to

implement". I am sorry I missed that earlier admission.

--
dorayme

Highlander

unread,
Feb 18, 2008, 10:09:41 AM2/18/08
to
On Feb 15, 7:37 pm, "MikeB" <m.byerleyATVerizonDottieNettie> wrote:
> "MikeB" <m.byerleyATVerizonDottieNettie> wrote in message
>
> news:%23Y6S$IDcIH...@TK2MSFTNGP04.phx.gbl...
>
>
>
> > "Highlander" <tron9...@msn.com> wrote in message

Thanks Mike! Your code works.

Now the question is, how do I insert your javascript code into the HTA
that I referred to:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0130.mspx

The resulting HTA needs to have both VBScript and javascript code.
What I'm looking for is the HTA to have a blank span initially; and
then when I click the button, the text of my choosing appears, and it
starts blinking in the manner that your javascript code commands it to
do.

Thanks!

- Dave

Paul Randall

unread,
Feb 18, 2008, 12:36:44 PM2/18/08
to

"Highlander" <tron...@msn.com> wrote in message
news:cd098a0d-5770-4ea1...@e25g2000prg.googlegroups.com...

http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0130.mspx

Thanks!

- Dave

Hi, Dave
If you don't already have it, download the HTA HelpOMatic.hta from
here:
http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=hta&DisplayLang=en

A basic HTA looks like this:
<html>
<head>
<title>Put your window title bar here</title>
<script language="vbscript">
'Putting this script here prepositions the window.
'Windowstate=Maximize would override this.
Const wdDlg = 600, htDlg = 380 ' dialog size
Const pxLeft = 100, pxTop = 100 ' positioning
window.ResizeTo wdDlg,htDlg
window.MoveTo pxLeft,pxTop
</SCRIPT>
<HTA:APPLICATION
ID="Put your ID here"
APPLICATIONNAME="Put your application name here"
SCROLL="yes"
SINGLEINSTANCE="no"
WINDOWSTATE=""
>
</head>

<SCRIPT Language="VBScript">
</SCRIPT>
<SCRIPT Language="JScript">
</SCRIPT>
<body>

</body>
</html>

The script near the beginning is something I've picked up in the M$
scripting newsgroup -- By being before the <HTA: ... > element, it
positions and sizes the HTA window before it is desplayed.

You can sprinkle <script> ... </script> blocks essentially anywhere
between the <head> and </html> tags. Each script block can specify
the language it uses; other languages like Perl, Python, Ruby, Rex,
and others can be installed. One hta can use a mixture of all the
scripting languages you have installed. Placing all the scripts in
front of the <body> tag helps with readability

You probably already know that subroutines and functions can be
specified to run when certain events associated with some object
occur. For example, the HTML for a button can specify a subroutine
name and arguments to be passed when the button's OnClick event is
invoked. Besides specifying the language, the <script ...> tag can
specify an object and an event name; the script within this script
block will only be executed in response to this event. Details of the
<script > element syntax is here:
http://msdn2.microsoft.com/en-us/library/ms535892(VS.85).aspx#

Functions and subroutines within the <script> ... </script> blocks are
only executed when they are called. The same is true when the <script
...> tag indicates that it is for a specific event for a specific
object. All other script is executed as it is encountered. You might
call this script the main program, although it can be parts of many
<script> ... </script> blocks in many languages. The blinking code
makes use of this:

> <SCRIPT type="text/javascript">
> var bBlinkON = false;

Variable bBlinkON is defined outside any function/sub, so it is a
global variable available immediately to any line of JScript executed
at a later time.

Some of the things you have to do are:
-copy the JScript blocks to some place ahead of your <body ... > tag.
-modify your <body ... > tag to set up event handlers.
-modify the script to use your span's ID.
-Add a button & click handler to modify the text in the span.

As demonstrated in the blinking code, you can get a reference to your
span with code like:
window.document.getElementById('spanToBlink')
As with most elements, this element has an innerhtml property which
you can change to any text you want.

If you find the HTA helpOMatic.hta handy, you can customize it --
adding selection items and HTML blocks and associated script blocks or
modifying the current ones to your liking.

-Paul Randall

ekkehard.horner

unread,
Feb 18, 2008, 1:53:12 PM2/18/08
to
Paul Randall schrieb:
[...]

> A basic HTA looks like this:
> <html>
> <head>
> <title>Put your window title bar here</title>
> <script language="vbscript">
> 'Putting this script here prepositions the window.
> 'Windowstate=Maximize would override this.
> Const wdDlg = 600, htDlg = 380 ' dialog size
> Const pxLeft = 100, pxTop = 100 ' positioning
> window.ResizeTo wdDlg,htDlg
> window.MoveTo pxLeft,pxTop
> </SCRIPT>
> <HTA:APPLICATION
> ID="Put your ID here"
> APPLICATIONNAME="Put your application name here"
> SCROLL="yes"
> SINGLEINSTANCE="no"
> WINDOWSTATE=""

missing a closing >

> </head>

wrong! no elements allowed between </head> and </body>

> <SCRIPT Language="VBScript">
> </SCRIPT>
> <SCRIPT Language="JScript">
> </SCRIPT>

the above script elements should be moved before the </head>

> <body>
> </body>
> </html>
[...]

ekkehard.horner

unread,
Feb 18, 2008, 1:54:50 PM2/18/08
to
ekkehard.horner schrieb:
> Paul Randall schrieb:
> [...]

> wrong! no elements allowed between </head> and </body>
wrong! no elements allowed between </head> and <body>
> [...]
Not my day, obviously!

Highlander

unread,
Feb 18, 2008, 2:13:47 PM2/18/08
to
> http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/h...

>
> The resulting HTA needs to have both VBScript and javascript code.
> What I'm looking for is the HTA to have a blank span initially; and
> then when I click the button, the text of my choosing appears, and it
> starts blinking in the manner that your javascript code commands it to
> do.
>
> Thanks!
>
> - Dave
>
> Hi, Dave
> If you don't already have it, download the HTA HelpOMatic.hta from
> here:http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=hta&D...
> -Paul Randall- Hide quoted text -

>
> - Show quoted text -

Thanks for the detailed response Paul.

I already have a good deal of experience creating HTAs, but using
VBScript code only. I've got no experience working with javascript. So
when Paul came up with the blinking text solution in javascript,
that's where I'm a little fuzzy - how to incorporate the javascript
code into my HTA.

I had already created an HTA which combined Paul's javascript code and
my own VBscript code; and I've got it close to working the way I want
it to - but not quite:

<html>
<head>


<TITLE>This is the Application Caption</TITLE>
<HTA:APPLICATION ID="oApp"

APPLICATIONNAME="Application Name Here"


BORDER="thick"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
CAPTION="YES"
ICON=""
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal">

<style type="text/css">
.textBlack {color : #000000;}
.textRed {color : #CC0000;}
</style>

</head>

<SCRIPT type="text/javascript">
var bBlinkON = false;
function SwapColors(valIN)
{if (valIN.className=='textBlack')
valIN.className='textRed';
else
valIN.className='textBlack';
return;}

function Init()
{var fSC = function (){
SwapColors(window.document.getElementById('spanToBlink'))};
var UpdateTime = window.setInterval(fSC,1000);}

function Terminate()
{window.clearTimeout();}
</SCRIPT>

<SCRIPT Language = "VBScript">
Sub DisplayText_OnClick
DataArea.InnerHTML = "Text of my choosing here."
End Sub
</SCRIPT>

<!--


<body onload="Init(); return false;">

-->
<body>
<div>
<input type="button" value="Blink Text" onclick="Init()">
<p>


<span id="spanToBlink" class="textBlack">This is my blinking Text!</
span>
</div>

<p>
<input name= "DisplayText" type="button" value="Display Text"><p>
<span id=DataArea></span>
</body>
</html>


If you notice in the VBScript subroutine 'DisplayText_OnClick', I'm
able to specify the text of my choosing:

DataArea.InnerHTML = "Text of my choosing here."

This is what I can't figure out how to do in the javascript function.

On the VBScript side, when I click the button 'DisplayText', text is
displayed in the span area; which was initially blank. I want the
javascript code to work the same way. In that when I click the button
'Blink Text', the span area, which was initially blank, will now
display blinking text.

Highlander

unread,
Feb 18, 2008, 2:24:21 PM2/18/08
to
> - Dave- Hide quoted text -

>
> - Show quoted text -

...when Paul came up with the blinking text solution in javascript...

I meant to say MIKE, not Paul. MikeB posted the blinking text solution
in javascript earlier in this thread.

Paul Randall

unread,
Feb 18, 2008, 5:05:55 PM2/18/08
to

"Highlander" <tron...@msn.com> wrote in message
news:b90fd013-939a-4e79...@u10g2000prn.googlegroups.com...

function Terminate()
{window.clearTimeout();}
</SCRIPT>

- Dave

I'm not good with JScript or styles. Hopefully someone else can help
you.

In theory, changing the contents of the span to an empty string should
eliminate the blinking text. VBScript can do that with:


DataArea.InnerHTML = "Text of my choosing here."

and
DataArea.InnerHTML = ""
As currently written, your script blinks all text in the specified
span and any text that may follow. I don't think that is what you
want.

I have a feeling that the sample script Mike gave you left something
out. I'm thinking the purpose of
var bBlinkON = false;
is to give you a variable that you can just toggle between True and
False in order to have the contents of the span blink or not.


Paul Randall

unread,
Feb 18, 2008, 6:06:17 PM2/18/08
to

"ekkehard.horner" <ekkehar...@arcor.de> wrote in message
news:47b9d47b$0$381$9b4e...@newsspool2.arcor-online.net...

It happens to everyone :-)

Scripts can be placed almost anywhere in the main HTA elements:

<html>
<script language="vbscript">
MsgBox "Entered <html> element"
</script>

<head>
<script language="vbscript">
MsgBox "Entered <head> element"
</script>

<title>

<script language="vbscript">
MsgBox "Scripts don't work within the title element"
</script>

Title: Script placement within HTA

</title>

<HTA:APPLICATION
ID="oHTA"


APPLICATIONNAME="Put your application name here"
SCROLL="yes"
SINGLEINSTANCE="no"
WINDOWSTATE=""

<script language="vbscript">
MsgBox "Scripts are ignored in <HTA:> element"
</script>

>

</head>

<script language="vbscript">
MsgBox "Exited <head> element"
</script>

<body>

<script language="vbscript">
MsgBox "Entered <body> element"
</script>

<input id=Test1 class="button" type="button"
value="Test 1" name="Test1" onClick="Test1.vbs">
<br>

<script language="vbscript">
MsgBox "One button should now be displayed in the HTA window"
</script>

<input id=Test2 class="button" type="button"
value="Test 2" name="Test2" onClick="Test2.vbs">
<br>

<script language="vbscript">
MsgBox "Two buttons should now be displayed in the HTA " & _
"window. VBScript's message box is modal - it blocks " & _
"the use of controls in the HTA window, or even " & _
"repositioning the HTA window. It would be interesting " & _
"to see an expanded test HTA that mixes languages and " & _
"demonstrates ways to pass variables between languages and " & _
"access functions and subroutines of alien languages."
</script>

</body>

<script language="vbscript">
MsgBox "Exited <body> element"
</script>

</html>


ekkehard.horner

unread,
Feb 19, 2008, 4:05:38 AM2/19/08
to
Paul Randall schrieb:
[...]

The statement

> Scripts can be placed almost anywhere in the main HTA elements:

and most of the samples are correct and valuable. But there is at
least one position, where <script> isn't allowed: between </head>
and <body>.

http://www.w3.org/TR/html4/struct/global.html#edef-HTML

To add something more productive:

<html>
<head>
<hta:application id = "search"
/>
<title>search</title>
<meta http-equiv = "content-type" content="text/html; charset=iso-8859-1"/>
<meta http-equiv = "content-script-type" content = "text/vbscript"/>
<style type = "text/css">
.stdBtt
{ width: 80;
}
.Meta
{ color: red;
}
</style>
<script language = "VBScript"
type = "text/vbscript"
>
'<![CDATA[

Option Explicit

''= globals
' ============================================================================
Dim gCursor : gCursor = Empty
Dim nCnt : nCnt = Empty

''= start searching
' ============================================================================
Sub doStart()
gCursor = document.body.style.cursor
nCnt = 0
pMsg.InnerTEXT = "Searching ... " & nCnt
document.body.style.cursor = "wait"
Worker
End Sub

''= do the work step by step
' ============================================================================
Sub Worker()
If nCnt >= 10 Then
pMsg.InnerTEXT = "Idle"
pMsg.Style.Color = "black"
document.body.style.cursor = gCursor
Else
nCnt = nCnt + 1
pMsg.InnerTEXT = "Searching ... " & nCnt
If 0 = (nCnt Mod 2) Then
pMsg.Style.Color = "blue"
Else
pMsg.Style.Color = "red"
End If
window.setTimeout "Worker", 500, "VBScript"
End If
End Sub

''= refreshes the HTA page, which includes re-running any Windows_Onload code
' ============================================================================
Sub reloadHTA()
location.reload True
End Sub

']]>
</script>
</head>
<body>
<hr />
<input id = "bttStart" class = "StdBtt" type = "BUTTON" value = "Start" onclick =
"doStart">
<hr />
<input class = "StdBtt Meta" type = "BUTTON" value = "reload" onclick = "reloadHTA">
<hr />
<p id = "pMsg">
Idle
</p>
</body>
</html>

Highlander

unread,
Feb 19, 2008, 11:03:58 AM2/19/08
to
On Feb 19, 3:05 am, "ekkehard.horner" <ekkehard.hor...@arcor.de>
wrote:
> ' ===========================================================================­=

> Dim gCursor : gCursor = Empty
> Dim nCnt    : nCnt    = Empty
>
> ''= start searching
> ' ===========================================================================­=

> Sub doStart()
>    gCursor = document.body.style.cursor
>    nCnt    = 0
>    pMsg.InnerTEXT = "Searching ... " & nCnt
>    document.body.style.cursor = "wait"
>    Worker
> End Sub
>
> ''= do the work step by step
> ' ===========================================================================­=

> Sub Worker()
>    If nCnt >= 10 Then
>       pMsg.InnerTEXT = "Idle"
>       pMsg.Style.Color = "black"
>       document.body.style.cursor = gCursor
>    Else
>       nCnt = nCnt + 1
>       pMsg.InnerTEXT = "Searching ... " & nCnt
>       If 0 = (nCnt Mod 2) Then
>          pMsg.Style.Color = "blue"
>       Else
>          pMsg.Style.Color = "red"
>       End If
>       window.setTimeout "Worker", 500, "VBScript"
>    End If
> End Sub
>
> ''= refreshes the HTA page, which includes re-running any Windows_Onload code
> ' ===========================================================================­=

> Sub reloadHTA()
>    location.reload True
> End Sub
>
> ']]>
>    </script>
>   </head>
>   <body>
>    <hr />
>    <input id = "bttStart" class = "StdBtt" type = "BUTTON" value = "Start" onclick =
> "doStart">
>    <hr />
>    <input class = "StdBtt Meta" type = "BUTTON" value = "reload" onclick = "reloadHTA">
>    <hr />
>     <p id = "pMsg">
>      Idle
>     </p>
>   </body>
> </html>

I came up with a blinking text solution in VBScript:

<html>
<head>


<TITLE>This is the Application Caption</TITLE>
<HTA:APPLICATION ID="oApp"

APPLICATIONNAME="Application Name Here"


BORDER="thick"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
CAPTION="YES"
ICON=""
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal">

</head>

<SCRIPT Language = "VBScript">
Dim sLoopStop, sTotals
sLoopStop = False

Sub CountEvents
DisplayText
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colEvents = objWMIService.ExecQuery("Select * From
Win32_NTLogEvent")
For Each objProcess in colEvents


i = i + 1

Next
sTotals = "Total events: " & i
StopLoop
End Sub

Sub DisplayText
IF sLoopStop = True Then
DataArea.InnerHTML = _
"<font color='green' face='Arial' size='4'><b>" & _
"Completed!!" & sTotals & "</b></font>"
Else
BlankText
ccSleep 1
RedText
End IF
End Sub

Sub BlankText
DataArea.InnerHTML = ""
End Sub

Sub RedText
DataArea.InnerHTML = _
"<font color='red' face='Arial' size='4'><b>" & _
"Processing..." & "</b></font>"
ccSleep 1
DisplayText
End Sub

Sub StopLoop
sLoopStop = True
End Sub

Sub ccSleep(seconds)
Set objShell = CreateObject("WScript.Shell")
cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul"
objShell.Run cmd,0,1
Set objShell = nothing
End Sub

</SCRIPT>
<body>
<input type="button" value="Display Text" onclick="DisplayText">
<p>
<input type="button" value="Stop Loop" onclick="StopLoop">
<p>
<hr>


<span id=DataArea></span>
</body>
</html>

It works fine, but now there's a new problem. Once the text starts
blinking, that's all the HTA does. I wanted additional processing to
be executing while the text is blinking.

When I click the 'Display Text' button, the 'CountEvents' subroutine
begins. It calls the 'DisplayText' subroutine, and the loop between
subroutines begins; the text starts to blink. But the additional code
in the 'DisplayText' subroutine - the WMI portion - never executes.

If I understand this correctly, this is due to the fact that by
default, when you call a procedure, once the procedure has finished
executing, control returns back to the code that called the procedure,
and execution picks up from there.

So is there any way around this? Any suggestions would be greatly
appreciated. Thanks!

- Dave

Paul Randall

unread,
Feb 19, 2008, 11:18:56 AM2/19/08
to
Thanks for the input, ekkehard.
I rather doubt that Microsoft intended the HTA structure requirements
to match the w3 standards for HTML.

My intent was to create an HTA that demonstrates what is/is not
allowed by M$, not what is/is not allowed by the HTML standard. It is
difficult to tell whether Microsoft's failure to enforce the standard
is a feature or a bug. Microsoft's documentation is typically so poor
that I often feel that trial and error is the only way explore a
product's capabilities. Much like a blind man trying to figure out
what an elephant is and how to use it ;-)

-Paul Randall

"ekkehard.horner" <ekkehar...@arcor.de> wrote in message

news:47ba9be3$0$2292$9b4e...@newsspool4.arcor-online.net...

Tom Lavedas

unread,
Feb 19, 2008, 3:48:38 PM2/19/08
to
On Feb 19, 11:03 am, Highlander <tron9...@msn.com> wrote:
> On Feb 19, 3:05 am, "ekkehard.horner" <ekkehard.hor...@arcor.de>
> wrote:
> > Paul Randall schrieb:
> > [...]
>
> > The statement
>
> > > Scripts can be placed almost anywhere in the main HTA elements:
{snip}

>
> It works fine, but now there's a new problem. Once the text starts
> blinking, that's all the HTA does. I wanted additional processing to
> be executing while the text is blinking.
>
> When I click the 'Display Text' button, the 'CountEvents' subroutine
> begins. It calls the 'DisplayText' subroutine, and the loop between
> subroutines begins; the text starts to blink. But the additional code
> in the 'DisplayText' subroutine - the WMI portion - never executes.
>
> If I understand this correctly, this is due to the fact that by
> default, when you call a procedure, once the procedure has finished
> executing, control returns back to the code that called the procedure,
> and execution picks up from there.
>
> So is there any way around this? Any suggestions would be greatly
> appreciated. Thanks!
>
> - Dave

There are too many problems with this to 'fix' it. So, I took a stab
at what I think you want using the setTimeout approach (I hate the
ping kludge for timing - plus, it leaves no time for processing).

I think you you want to consider something more like this ...

<html>
<!-- put your HTA header Here -->
<SCRIPT Language = "VBScript">
Dim objWMIService, bLoopStop, nTotals, bBlank, sRedHTML, sGrnHTML

Sub initiate
sRedHTML = "<font color='red' face='Arial' size='4'><b>" & _
"Processing ...</b></font>"
sGrnHTML = "<font color='green' face='Arial' size='4'><b>" & _
"Completed!! Total Count: nTotals</b></font>"

bBlank = True
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer _
& "\root\cimv2")
DataArea.InnerHTML = "Ready"

end sub

Sub CountEvents
Set colEvents = objWMIService.ExecQuery(_


"Select * From Win32_NTLogEvent")

nTotals = nTotals + colEvents.count
if bBlank then
DataArea.InnerHTML = sRedHTML
else
DataArea.InnerHTML = ""
end if
bBlank = not bBlank
if not bLoopStop then
setTimeout "CountEvents", 250, "vbscript"
else
DataArea.InnerHTML = Replace(sGrnHTML, "nTotals", nTotals)
end if
End Sub

</SCRIPT>
<body onload=initiate>


<input type="button" value="Display Text"

onclick="bLoopStop=False:CountEvents">
<p>
<input type="button" value=Stop onclick="bLoopStop=True">

Highlander

unread,
Feb 19, 2008, 4:30:46 PM2/19/08
to
> </html>- Hide quoted text -

>
> - Show quoted text -

Thanks Tom this works great! There's just one more thing I need.

Is there a way to tell when the 'colEvents.count' is finished, stops
incrementing, and the value of 'nTotals' does not go any higher? Then
at that point, 'bLoopStop' is set to 'True', and the 'Completed'
message is displayed.

Essentially I'd like a way for the blinking text to stop
programmatically, as an alternative to hitting the "Stop" button.

Thanks again!

- Dave

Tom Lavedas

unread,
Feb 20, 2008, 11:01:06 AM2/20/08
to

{snip code}

> > - Show quoted text -
>
> Thanks Tom this works great! There's just one more thing I need.
>
> Is there a way to tell when the 'colEvents.count' is finished, stops
> incrementing, and the value of 'nTotals' does not go any higher? Then
> at that point, 'bLoopStop' is set to 'True', and the 'Completed'
> message is displayed.
>
> Essentially I'd like a way for the blinking text to stop
> programmatically, as an alternative to hitting the "Stop" button.
>
> Thanks again!
>
> - Dave

I hadn't followed this whole thread, so I missed your full
intentions. I just reviewed it to try to better understand. Now I
realize that what you are actually trying to accomplish CANNOT be done
easily. The problem is that the underlying process hogs all of the
process time, such that there is no time left to process the text
blink. To have the text blink while the main process is working, the
two must be run asynchronously (in two separate threads) - which is
just not done simply in script.

It is reasonably easy to launch an asynchronous process, but
communicating its results back to the calling routine is complicated.
It's also an issue to determine if the process has finished. A
temporary file could be used to retrieve the result or a registry key
could be used, as well. Michael Harris also published an approach
some years back that uses an IE 'pipe', which has some advantages, but
is even more complicated.

One approach to launching the asynchronous process is to use Execute
method of the Shell.Application and then monitor the PID that results
to see if it's still in existence. Though I can describe the process,
I've never done it, so it would take some work to get it right - time
I don't have at the moment. Another approach is to use the
Wscript.Shell's Exec method, but that presents an ugly command console
window as it runs. There are probably others.

As I said, I don't have time to explore this anymore now, but might be
able to get back to you sometime in the future (maybe in a few days -
maybe). Sorry.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Tom Lavedas

unread,
Feb 22, 2008, 10:29:03 AM2/22/08
to
On Feb 20, 11:01 am, Tom Lavedas <tglba...@cox.net> wrote:
> On Feb 19, 4:30 pm, Highlander <tron9...@msn.com> wrote:
>
>
>
> > On Feb 19, 2:48 pm, Tom Lavedas <tglba...@cox.net> wrote:
>
> > > On Feb 19, 11:03 am, Highlander <tron9...@msn.com> wrote:
>
> > > > On Feb 19, 3:05 am, "ekkehard.horner" <ekkehard.hor...@arcor.de>
> > > > wrote:
> > > > > Paul Randall schrieb:
> > > > > [...]
>
{snip}

> As I said, I don't have time to explore this anymore now, but might be
> able to get back to you sometime in the future (maybe in a few days -
> maybe). Sorry.
>
> Tom Lavedas
> ===========
> http://members.cox.net/tglbatch/wsh/

OK, here is what I was able to put together. It uses the windows
showModelessDialog method as the 'asynchronous' process to show the
flashing text. As you can probably see, it's rather an involved
undertaking.

<html>
<!-- Your HTA header goes here -->
<SCRIPT Language = "VBScript">
Dim g_sGrnHTML, g_MsgArea

Sub Runit
DataArea.InnerHTML = "<font face='Arial' size='4'><b>" _
& "Running</b></font>"
nLeft = screenleft : nTop = screentop
set g_MsgArea = window.showModelessDialog("about:blank", null, _
"dialogLeft:" & nLeft & "px;dialogTop:" & ntop _
& "px;dialogHeight:100px;dialogWidth:400px;" _
& "center:no;scroll:no;status:no;resizable:no")
with g_MsgArea.document
.open
.writeln "<html><head><title>Working - patience please"
.writeln "</title></head><SCRIPT Language='VBScript'>"
.writeln "Dim g_bBlank, g_sRed"
.writeln "sub startit"
.writeln "g_sRed=""<br><font color=red face=Arial size=4>" _
& "<center><b>Processing ...</b></center></font>"""
.writeln "setInterval ""Blink"", 250, ""vbscript"" "
.writeln "end sub"
.writeln "Sub Blink"
.writeln " if g_bBlank then"
.writeln " MsgArea.InnerHTML=g_sRed"
.writeln " else"
.writeln " MsgArea.InnerHTML="""""
.writeln " end if"
.writeln " g_bBlank=not g_bBlank"
.writeln "end sub"
' *DO NOT* remove the 'unnecessary' concatenation from next line
.writeln "</" & "script><body onload='startit'>"
.writeln "<span id=MsgArea></span></body></html>"
.close
Do Until .ReadyState = "complete" : Loop
End with
g_sGrnHTML = "<font color='green' face='Arial' size='4'><b>" & _


"Completed!! Total Count: nTotals</b></font>"

setTimeout "CountEvents", 50, "vbscript"
end sub

Sub CountEvents
Dim n, i
strComputer = "."
Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set cEvents = oWMI.ExecQuery("Select * From Win32_NTLogEvent")
'
' This loop is just here to slow things down as an example of a
' long running process
'
for i = 1 to 100*cEvents.count
n = n + 1
next
'
DataArea.InnerHTML = Replace(g_sGrnHTML, "nTotals", cEvents.count)
g_MsgArea.close
End Sub

</SCRIPT>
<body onload=Runit>
<input type="button" value=" Run " onclick="Runit">
<p><hr><p><span id=DataArea></span></body></html>

IHTH - I actually enjoyed the challenge of putting it together. I
learned a bunch.

0 new messages