Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Custom Msgbox

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2980
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Custom Msgbox
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Custom Msgbox - 5/12/2005 2:55:32 PM   
  ttleser

 

Posts: 3
Score: 0
Joined: 5/12/2005
From:
Status: offline
First off, I want to say that my knowledge of VBscript is extremely novice boardering on stupid. ;)

I own a gaming center (with 20 PCs) and I have a cafe software that requires my customer to sign into. When they want to play a certain game, they locate it in the menu selection and launch it. The game, in the background, copies user files from a file server and then launch the game (using batch files I wrote). There are a couple of games that I have that require you to signin, they are MMORPGs (Massively Mutliplayer Online Role Playing Game). The customer will need to have their own account to be able to play these games, except one game which I have 3 in-store account available for usage. What happens is when the customer wants to play the game, they select it from the menu select, but I've got a little VBScript that displays a message telling them that this is a "MMORPG and requires them to have an account". If they click "yes" and get to the game's signin screen, they call me over and I sign in with one of my 3 accounts for them to play with. Ok, enough of the background info.

I'd like to have another display window that would come up that would ask them which account they are using, ie... Account1, Account2, Account3 or personal account. After they click one of those 4 buttons, the game will launch just like it does now and I'd still have to sign into the game with one of the 3 accounts. I'd also like the script to export the selection they/me made to a text file, and preferibly upload it to a ftp/web server. I'd like to have my flash web page to be able to display with of my accounts are in use (which I can do, I think) . The export would need to allow for 3 instances of the game being run (not all at the same pc) so that any previous export isn't overwritten.

Breath...

Ok, so what I need to know is:

1. How to create a custom msgbox window with my own buttons (other than the standard yes/no, ok/cancel, etc...)
2. How to export that selection to a text file (either on a local server or on the Internet.
3. If the export can't save directly to the web, how to ftp upload the exported text file to a ftp/web server.

Thanks a load. ;)
 
 
Post #: 1
 
 Re: Custom Msgbox - 5/12/2005 8:52:06 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
In order to create a screen where the customer selects an account, you could make a script that creates an HTA (=HTML application).
With HTAs you can use everything you can use in HTML, including CSS, which gives you the opportunity to design the screen to your needs.
This HTA can create a textfile to write the selection to.
I made an example which should get you started.
The script will create an HTA on the desktop (MySelectionScreen.hta) and runs this HTA.
The HTA itself will then create a textfile on the desktop (Selection.txt), kills itself and deletes itself.
Resulting in a textfile on the desktop with the selection written to it.
      HTH

(in reply to ttleser)
 
 
Post #: 2
 
 Re: Custom Msgbox - 5/13/2005 2:37:58 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
another alternative is to use an input box as a menu,


      

(in reply to ttleser)
 
 
Post #: 3
 
 Re: Custom Msgbox - 5/13/2005 6:34:16 AM   
  ttleser

 

Posts: 3
Score: 0
Joined: 5/12/2005
From:
Status: offline
Thanks to all for the input so far. ;)

> Zifter
I wanted to see what your example would do, so I saved the text to a .VBS file, a .HTA file, a .HTML file and couldn't get it to work with any format. All it would display is the text of the code. What am I doing wrong? Remember I told you I was very novice at this. ;)

> kirrilian
I'd like to avoid input boxes if possible, make it as **** proof as possible as well as I'd prefer my customers don't know the name of my accounts, the labels I'd use on the buttons would be more... generic. I tried it anyways and I get an error on line 11, character 2. It's the Set fso = CreateObject("Scripting.FileSystemObject") line I think .;)

(in reply to ttleser)
 
 
Post #: 4
 
 Re: Custom Msgbox - 5/13/2005 6:51:50 AM   
  ttleser

 

Posts: 3
Score: 0
Joined: 5/12/2005
From:
Status: offline
OK, I searched a little on the web and found that the code needs to be in HTML format as well as have the <html> tags in it. OK, I tested it again and this time it created an HTA file and when I ran that it gave me a big IE window with the 4 options in it. I guess I've got a few more questions.

1. Once the .HTA file was run, it got deleted. I'd need it to not be deleted once it's run. I'd need to have it run anytime a customer wants to play that game.

2. Can I have the window sized to something smaller? You mentioned using CSS file, unfortuately I don't have any experience with Cascading Style Sheets either, would CSS allow me to have the window sized appropriately?

3. Can this method allow for uploading to a site, or do I just have the script put on a website and have my cafe software use the script on the site?

4. I also noticed that the selection.txt file is over written with each new selection made. Any way to have a different selection file created depending on which choice is made? For example, customer chooses Account1 then account1.txt file would be created. This way if Account2 is chosen on other PC at the same time, the other text file wouldn't get deleted.

5. I noticed in the code:
objMyHTA.WriteLine "<td><input type=radio name=Acc value=Acc1>Account 1</input></td>"
That it outputs the text "Acc1", is there a way to change it to include a space? For example, change "Acc1" to "In Use". I can change it to "In Use", but it'll only show "In".

ok, yet one more update to this post.
I noticed in your post that you said once the html file is run, it should run the HTA file. So I re-ran it again and noticed in the lower right corner of the IE window that it says it's done with errors, when I do a details on it, it says:
Line: 65
Char: 1
Error: The system cannot find the file specified.
Code: 0
URL: file://c:\documents and settings\administrator\Desktop\test.html

Looking at line 65, it's:
objShell.Run strDesktopPath & "\MySelectionScreen.hta"

Not sure what's causing the error in this line. Here's the full code I used:
<html>
<script language=vbscript type=text/vbscript>
<!--

Option Explicit

Dim objFso
Dim objShell
Dim strDesktopPath
Dim objMyHTA

Set objFso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

strDesktopPath = objShell.SpecialFolders("Desktop")
Set objMyHTA = objFso.CreateTextFile(strDesktopPath & "\MySelectionScreen.hta")
objMyHTA.WriteLine "<html>"
objMyHTA.WriteLine "<hta:application>"
objMyHTA.WriteLine "<head>"
objMyHTA.WriteLine "<script language=VbScript>"
objMyHTA.WriteLine "Function fnCheckSelection()"
objMyHTA.WriteLine " For i = 0 To document.all.Acc.length -1"
objMyHTA.WriteLine " If document.all.Acc(i).checked=True Then"
objMyHTA.WriteLine " fnWriteSelection(document.all.Acc(i).value)"
objMyHTA.WriteLine " End If"
objMyHTA.WriteLine " Next"
objMyHTA.WriteLine "End Function"
objMyHTA.WriteLine "Function fnWriteSelection(val)"
objMyHTA.WriteLine " Set objFso = CreateObject(" & Chr(34) & _
"Scripting.FileSystemObject" & Chr(34) & ")"
objMyHTA.WriteLine " Set objMyOutput = objFso.CreateTextFile(" & Chr(34) & _
strDesktopPath & "\Selection.txt" & Chr(34) & ")"
objMyHTA.WriteLine " objMyOutput.WriteLine val"
objMyHTA.WriteLine " objMyOutput.Close"
objMyHTA.WriteLine " objFso.DeleteFile(" & Chr(34) & strDesktopPath & _
"\MySelectionScreen.hta" & Chr(34) & ")"
objMyHTA.WriteLine " Window.Close"
objMyHTA.WriteLine " Set objMyOutput = Nothing"
objMyHTA.WriteLine " Set objFso = Nothing"
objMyHTA.WriteLine "End Function"
objMyHTA.WriteLine "</script>"
objMyHTA.WriteLine "</head>"
objMyHTA.WriteLine "<body>"
objMyHTA.WriteLine "<table>"
objMyHTA.WriteLine "<tr>"
objMyHTA.WriteLine "<td><input type=radio name=Acc value=Account1>Account 1</input></td>"
objMyHTA.WriteLine "</tr>"
objMyHTA.WriteLine "<tr>"
objMyHTA.WriteLine "<td><input type=radio name=Acc value=Account2>Account 2</input></td>"
objMyHTA.WriteLine "</tr>"
objMyHTA.WriteLine "<tr>"
objMyHTA.WriteLine "<td><input type=radio name=Acc value=Account3>Account 3</input></td>"
objMyHTA.WriteLine "</tr>"
objMyHTA.WriteLine "<tr>"
objMyHTA.WriteLine "<td><input type=radio name=Acc value=Personal>Personal</input></td>"
objMyHTA.WriteLine "</tr>"
objMyHTA.WriteLine "<tr>"
objMyHTA.WriteLine "<td><input type=button value=OK OnClick=fnCheckSelection()></td>"
objMyHTA.WriteLine "</tr>"
objMyHTA.WriteLine "</table>"
objMyHTA.WriteLine "</body>"
objMyHTA.WriteLine "</html>"
objMyHTA.close

objShell.Run strDesktopPath & "\MySelectionScreen.hta"

Set objMyHTA = Nothing
Set objShell = Nothing
Set objFso = Nothing
'-->
</script>

</body>
</html>

(in reply to ttleser)
 
 
Post #: 5
 
 Re: Custom Msgbox - 5/16/2005 7:26:42 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
You should have saved it with an extension .vbs
If this file is double clicked, the script should run, creating a temporary HTA (as custom messagebox), which writes the selected account to a textfile.
The reason why the script didn't run when you double clicked it, is most probably because in your Windows settings the filetype ".vbs" is not associated with Windows Scripting Host but with Notepad or something similar. You can solve this by changing the filetype in Windows Explorer or Right click on the ".vbs" file and choose the option "Open with..." and there you select the Windows Scripting Host.

I made it like this (a script that will create a temporary HTA that writes to a textfile and then kills itself) because you've asked how to make a 'custom messagebox' and this is how I would do it.

Actually in your case you don't need to do it with a script. You can do it all in a HTA (one that isn't first created and deleted afterwards).

I made a new example.
This time you should save it with a HTA extension.
This program will look at a textfile "Selection.txt" on your desktop to check which accounts are selected (in use) and which aren't.
When you press the "OK" button, this textfile will be updated with the new selections.

The only part you will have to change is the location (and maybe the name) of this textfile. If you have a network share on your server, you could use that path to point to the textfile.
      HTH

(in reply to ttleser)
 
 
Post #: 6
 
 Re: Custom Msgbox - 5/17/2005 2:32:09 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
quote:
Originally posted by ttleser

Thanks to all for the input so far. ;)

> kirrilian
I'd like to avoid input boxes if possible, make it as **** proof as possible as well as I'd prefer my customers don't know the name of my accounts, the labels I'd use on the buttons would be more... generic. I tried it anyways and I get an error on line 11, character 2. It's the Set fso = CreateObject("Scripting.FileSystemObject") line I think .;)



you have to change the output variable to a valid path.

(in reply to ttleser)
 
 
Post #: 7
 
 Re: Custom Msgbox - 5/18/2005 11:47:01 AM   
  marcusrp

 

Posts: 145
Score: 0
Joined: 4/19/2005
From:
Status: offline
zifter, I'd like to use your HTA page in a vbscript, but I need to assign the radio button inputs to variables that I can use later on in the script. how would I do that? thanks

(in reply to ttleser)
 
 
Post #: 8
 
 Re: Custom Msgbox - 5/18/2005 6:40:27 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
Not sure what you need...
All radiobuttons need to have the same name to make them mutually exclusive.
Since they all have the same name you will have to itterate through the collection of radiobuttons to retrieve the state, value,... of each individual radiobutton.
      "document.all.Acc" is a control array of all the radiobuttons (assuming they all have the name "Acc").
In a For-Loop, we'll use the variable "i" starting from 0 (arrays are zero based) till the length of the array (= number of radiobuttons) minus one as index to examine each radiobutton separately.
If the "checked" property of a certain radiobutton is true (since we use radiobuttons, there can be only one (sounds familiar)), the value of that radiobutton is assigned to the variable "strValue".
So after the For-Loop the variable "strValue" contains the value of the selected radiobutton.

HTH

(in reply to ttleser)
 
 
Post #: 9
 
 Re: Custom Msgbox - 5/19/2005 5:05:15 AM   
  marcusrp

 

Posts: 145
Score: 0
Joined: 4/19/2005
From:
Status: offline
cool, that should work. I wasn't sure how to assign 'strValue' a value based on your array variables...not too familiar with HTML so the format of your array name was throwing me off...thanks!

>>>For i = 0 To document.all.Acc.length -1
If document.all.Acc(i).checked=True Then
strValue = document.all.Acc(i).value
End If
Next--------------------------------------------------------------------------------
"document.all.Acc" is a control array of all the radiobuttons (assuming they all have the name "Acc").
In a For-Loop, we'll use the variable "i" starting from 0 (arrays are zero based) till the length of the array (= number of radiobuttons) minus one as index to examine each radiobutton separately.
If the "checked" property of a certain radiobutton is true (since we use radiobuttons, there can be only one (sounds familiar)), the value of that radiobutton is assigned to the variable "strValue".
So after the For-Loop the variable "strValue" contains the value of the selected radiobutton.<<<<

(in reply to ttleser)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Custom Msgbox Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts