Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This forum is the most helpful site I've ever used. I used to use Deja.com; but, this site is better - hands down!..."

Geography

Where in the world do Tek-Tips members come from?

Method Popup in HTA didn't work ?

crackoo (Programmer)
13 Aug 12 0:09
Hi
i wonder why the Method Popup didn't work in a HTA, but in Vbscript works!
exemple : i want to perform a message Box waiting for 7 seconds and it close by it self if there is no intervention by the User:

VBS

CODE

Sub Popup()
Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")
 
BtnCode = WshShell.Popup("Comment allez-vous ?", 7, "Répondez à cette Question:", 4 + 32)
 
Select Case BtnCode
   case 6      WScript.Echo "Je suis ravie d'apprendre que vous allez bien."
   case 7      WScript.Echo "J'espère que vous irez mieux."
   case -1     WScript.Echo "Y-a-t-il quelqu'un ?"
End Select
End Sub
Call Popup 

HTA

CODE

<html>
<head>
<title>Question</title>
<HTA:APPLICATION 
APPLICATIONNAME="Question"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<script language="VBScript">
Sub Popup()
Dim WshShell, BtnCode
Set WshShell = CreateObject("WScript.Shell")
 
BtnCode = WshShell.Popup("Comment allez-vous ?", 7, "Répondez à cette Question:", 4 + 32)
 
Select Case BtnCode
   case 6      WScript.Echo "Je suis ravie d'apprendre que vous allez bien."
   case 7      WScript.Echo "J'espère que vous irez mieux."
   case -1     WScript.Echo "Y-a-t-il quelqu'un ?"
End Select
End Sub
</script>
</head>
<body>
<input type="button" value="Question" name="run_button"  onClick="Popup"><p> 
</body>
</html> 

So in HTA the message Box freezes and don't close by it self why ?
guitarzan (Programmer)
13 Aug 12 9:02
You need colons after the Case conditions, and you can't use wscript.echo if you are running your code in an HTA.

Try:

CODE

Select Case BtnCode
   case 6: Msgbox "Je suis ravie d'apprendre que vous allez bien."
   case 7: Msgbox WScript.Echo "J'espère que vous irez mieux."
   case -1: Msgbox WScript.Echo "Y-a-t-il quelqu'un ?"
End Select 
crackoo (Programmer)
13 Aug 12 13:51
I think the problem come that WScript objects are not supported in HTA.
So to bypass this limitation, i used this trick : generate a temporary vbscript file and execute it like this :

CODE

<html>
<head>
<title>Question</title>
<HTA:APPLICATION
APPLICATIONNAME="Question"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<script language="VBScript">
Sub Popup(Msg,Wait,Title)
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set ws  = CreateObject("WScript.Shell")
 Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
 Dim tempName : tempName = "Popup.vbs"
  Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
  objOutputFile.Writeline "Set WshShell = CreateObject(""WScript.Shell"")"
  objOutputFile.WriteLine "BtnCode = WshShell.Popup("&qq(Msg)&","&qq(wait)&","&qq(Title)&", 4 + 32)"
  objOutputFile.WriteLine "Select Case BtnCode"
  objOutputFile.WriteLine "case 6      MsgBox ""Je suis ravie d'apprendre que vous allez bien !"" ,64,""Je suis ravie d'apprendre que vous allez bien !"""
  objOutputFile.WriteLine "case 7      MsgBox ""J'espère que vous irez mieux !"",64,""J'espère que vous irez mieux !"" "
  objOutputFile.WriteLine "case -1     MsgBox ""Y-a-t-il quelqu'un ?"",vbQuestion,""Y-a-t-il quelqu'un ?"" "
  objOutputFile.WriteLine "End Select"
  objOutputFile.Close
  ws.Run tempFolder&"\"&tempName
End Sub
 
Function qq(strIn)
    qq = Chr(34) & strIn & Chr(34)
End Function
</script>
</head>
<body>
<input type="button" value="Question" name="run_button"  onClick="Popup 'Comment allez-vous ?','5','Répondez à cette Question'"><p>
</body>
</html> 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close