Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to scroll the text in the title bar in an HTA with Vbscript

Status
Not open for further replies.

crackoo

Programmer
Feb 17, 2011
132
TN
I am looking for an equivalent function in Vbscript if it's possible, to scroll the text in the title bar in an HTA like this function but it's written in javascript:

Code:
<html>
<script language="JavaScript">
 var txt=" Hello how are  You ? This a Demo for scrolling the Title bar !  so Enjoy it (^_^) ";
 var vitesse=1000;
 var refresh=null;
 function scroll_title() {
 document.title=txt;
 txt=txt.substring(1,txt.length)+txt.charAt(0)
 refresh=setTimeout("scroll_title()",vitesse);
 }
 scroll_title();
 </script>
 </html>

Thank you !
 
Ok This is a function to circumvent the problem of the WScript.Sleep in HTA [2thumbsup]
Code:
Sub Sleep(MSecs)' Fonction pour faire une pause car wscript.sleep ne marche pas dans un HTA 
	Set fso = CreateObject("Scripting.FileSystemObject")
	Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
	Dim tempName : tempName = "Sleeper.vbs"
	If Fso.FileExists(tempFolder&"\"&tempName)=False Then
		Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
		objOutputFile.Write "wscript.sleep WScript.Arguments(0)"
		objOutputFile.Close
	End If
	CreateObject("WScript.Shell").Run tempFolder&"\"&tempName &" "& MSecs,1,True
End Sub
So from now and with this new function can we simulate it
Thank you for your reply !
 
Clever work-around! Still, an abandoning problem exists. JS is asynchronous - you can set a timer to trigger an action and move on. VBS is synchronous - you can set a timer to trigger an action but you'll have to wait for the timer to expire in order move on. Depending on how you code the scrollTitle() function, you could end up with a "selfish," non-interactive HTA or an infinite recursive loop. Additionally, there are no clock cycles available (their too busy keeping time) to update the display. Either way, from the user's point a view, this results in a "Not Responding" application. :(

As far as I'm concerned, I don't think it's possible with today's tools.

-Geates



 
Hi [wavey3]
I solved the problem like this [2thumbsup]
Code:
<html>
<HTA:APPLICATION 
APPLICATIONNAME = "Scrolling the Title bar"
SINGLEINSTANCE = "yes" 
SCROLL = "no"
MAXIMIZEBUTTON = "no"
SELECTION = "no"
CONTEXTMENU = "no"
BORDER = "thin"
INNERBORDER = "no"
SYSMENU="no"
></HTA:APPLICATION>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<title>Salut ! comment allez-vous ? Voici une démonstration pour faire défiler la barre de titre ! (^_^)</title>
<head>
<script language="vbscript">
Dim refresh
VBtxt=" Hi ! How are you ? Here is a demonstration to scroll the title bar! (^ _ ^) | Salut ! comment allez-vous ? Voici une démonstration pour faire défiler la barre de titre ! (^_^) "
VBvitesse="150"

Sub Window_OnLoad()
	CenterWindow 450,90
	refresh=setInterval("VBscroll_title()",VBvitesse,"Vbscript")	
End sub

Sub CenterWindow(x,y)
	window.resizeTo x, y
	iLeft = window.screen.availWidth/2 - x/2
	itop = window.screen.availHeight/2 - y/2
	window.moveTo ileft, itop
End Sub

Function VBScroll_Title()
Document.title=vbtxt 
vbtxt=mid(vbtxt,2,len(vbtxt)) & left(vbtxt,1)
End Function

Sub Fermer()
Question = MsgBox("Voulez-vous Fermer cette Application ?",VBYesNO+VbQuestion,"Fermeture de l'application")
If Question = VbYes Then
Window.close
Else
    Exit Sub
End If
End Sub

Sub bpStop_OnClick 
Clear=ClearInterval(refresh)
Document.title="Hackoo Crackoo salute you (-_°)"
End Sub

Sub Start()
refresh=setInterval("VBscroll_title()",VBvitesse,"Vbscript")
End Sub
</script>
</head>
<body bgcolor="ButtonFace" style="cursor:hand;" ondblclick="Fermer()" Title=" 2 Double clics pour fermer l'application">
<center><input type="button" value="Start Scrolling" OnClick="Start()">
<input type="button" name="bpStop" value="Stop Scrolling">
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top