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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hta application to submit url and create multiple tabs

Status
Not open for further replies.

cbsarge

IS-IT--Management
Jun 20, 2001
219
US
I'm trying to build an hta that will accept a number (for the number of tabs) and a URL (opens in all the tabs). These 2 values are to be input by the user. My work in progress below is NOT functioning. :-(

Can someone help?

Code:
<head>
<title>test app</title>
<HTA:APPLICATION 
     APPLICATIONNAME="test app"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<style type="text/css">
body { 
font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color:#CCCCCC; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6699FF',EndColorStr='#FFFFFF');

p {font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif}
p {color: black}
p {font-size: 100%}
p.body {
padding: 4px; 
margin: 4px;
}
h1 {font-size: 130%}
h1 {color: #000099}
table.tools {
border:2px solid;
width: 98%;
border-top-color: #E6E6E6;
border-bottom-color: #000099;
border-right-color: #000099;
border-left-color: #CCCCCC;
font: 14px Verdana, Arial, Helvetica, sans-serif
}
td {
color: #000099;
font: 14px Verdana, Geneva, Arial, Helvetica, sans-serif;
border-color: #000099;
}
td {vertical-align:middle}
td.button {
width: 212px;
padding: 0px;
background-color: ##6699FF;
}
td.every {
background-color: white;
padding-left: 6px;
}
td.other {
background-color: #E5ECFF;
padding-left: 6px;
}
input.button {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: 14px;
background-color: #000099;
color: white;
width:211px;
height: 40px;
}
} 
.style2 {
	border-style: solid;
	border-width: 1px;
}
} 
.style2b {
	border-style: solid;
	border-width: 1px;
	background-color: #000099;
	color: white;
	padding-left: 6px;
}

</style>
</head>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 400,400
    End Sub 
</SCRIPT>

<body>
<div>
<table class="tools" cellspacing="0">
<tr>
<td class="button">

<form action="" onSubmit="ServiceChecker_Onclick()" method="get" target="_blank" >
number of tabs: <input type="text" name="strNUM" value="" ><br >
tab URL: <input type="text" name="strURL" value="" ><br >
<input type="submit" value="Submit" >
</form>

<script language="VBScript">
Sub ServiceChecker_Onclick
Dim strNum
Dim WshShell
msgbox "hello"
Set WshShell = CreateObject("WScript.Shell")
set i = strNum
  Do Until i=0
  i=i-1
  WshShell.Run ("chrome.exe" & Space(1) & strURL)
  If i<1 Then Exit Do
Loop
End Sub
</script>

</td>
<td class="other"></td>
</tr>
</table>
</div>
<br>
<br>
</body>

[!]The AutoSavers![/!] [2thumbsup]
 
At least replace this:
set i = strNum
with this:
i = strNum

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That helped a bit but, it's not launching the URLs in chrome or any other browser. What I get instead is an instance of internet explorer with the hta file path in the address bar with ?strNUM=4&strURL= (if I enter a 4 and in the text fields).

By the way, the msgbox is only there so I know the script runs.

[!]The AutoSavers![/!] [2thumbsup]
 
I think I'm getting closer. I added a couple other functions and am using the onchange function. I thought this would asign the variable values when the user clicked outside of the text fields which it seems to do. The problem is it doesn't seem to carry up to the function that does the real work. I put a line in there that says if strNUM = zero to alert "all done" and this seems to come up no matter what I put in the text field. Same with the URL - it always just opens to my home page.

Argh!

Code:
<head>
<title>test app</title>
<HTA:APPLICATION 
     APPLICATIONNAME="test app"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<style type="text/css">
body { 
font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color:#CCCCCC; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6699FF',EndColorStr='#FFFFFF');

p {font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif}
p {color: black}
p {font-size: 100%}
p.body {
padding: 4px; 
margin: 4px;
}
h1 {font-size: 130%}
h1 {color: #000099}
table.tools {
border:2px solid;
width: 98%;
border-top-color: #E6E6E6;
border-bottom-color: #000099;
border-right-color: #000099;
border-left-color: #CCCCCC;
font: 14px Verdana, Arial, Helvetica, sans-serif
}
td {
color: #000099;
font: 14px Verdana, Geneva, Arial, Helvetica, sans-serif;
border-color: #000099;
}
td {vertical-align:middle}
td.button {
width: 212px;
padding: 0px;
background-color: ##6699FF;
}
td.every {
background-color: white;
padding-left: 6px;
}
td.other {
background-color: #E5ECFF;
padding-left: 6px;
}
input.button {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: 14px;
background-color: #000099;
color: white;
width:211px;
height: 40px;
}
} 
.style2 {
	border-style: solid;
	border-width: 1px;
}
} 
.style2b {
	border-style: solid;
	border-width: 1px;
	background-color: #000099;
	color: white;
	padding-left: 6px;
}

</style>
<script language="VBScript">
Sub ServiceChecker_Onclick()
Dim strURL
Dim strNUM
Dim WshShell
Dim i
i = 1
if i=strNUM Then
  alert("all Done")
Else
Set WshShell = CreateObject("WScript.Shell")
  WshShell.Run("chrome.exe" & Space(1) & strURL)
  i = i + 1
End If
End Sub

Sub strNUM
Dim strNum
Dim formURL  
strNUM = formNUM
End Sub

Sub strURL
Dim strURL
Dim formURL 
strURL = formURL
End Sub

</script>
</head>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 400,400
    End Sub 
</SCRIPT>

<body>
<div>
<table class="tools" cellspacing="0">
<tr>
<td class="button">

<form name="NUM" >
number of tabs: <input type="text" name="formNUM" value="" onchange="strNUM()" >
</form>

<form name="URL" >
tab URL: <input type="text" name="formURL" value="" onchange="strURL()" >
</form>

<form name="formHTA" >
<input type="button" value="Submit" onclick="ServiceChecker_Onclick()" >
</form>

</td>
<td class="other"></td>
</tr>
</table>
</div>
<br>
<br>
</body>

[!]The AutoSavers![/!] [2thumbsup]
 
[0] Make sure the path is such on the m/c, if not, modify it to reflect the exact location accordingly.
[tt]
Set WshShell = CreateObject("WScript.Shell")
dim shomedrv, shomepath, spath
shomedrv=WshShell.expandenvironmentstrings("%homedrive%")
shomepath=WshShell.expandenvironmentstrings("%homepath%")
spath=shomedrv & shomepath & "\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
[/tt]
[1] And then use it explicitly.
[tt]
WshShell.Run chr(34) & spath & chr(34) & Space(1) & strURL
[/tt]
 
I believe I have correctly incorporated your suggestions but, it doesn't seem to be passing the URL or the number of tabs to the script portion of the hta. All it does is open Chrome in one tab to my home page and I think it only opens that because I have the i variable set to 1 instead of 0 where it should be starting. I've included the current code with the i variable still set to 1.

Code:
<head>
<title>test app</title>
<HTA:APPLICATION 
     APPLICATIONNAME="test app"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<style type="text/css">
body { 
font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color:#CCCCCC; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6699FF',EndColorStr='#FFFFFF');

p {font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif}
p {color: black}
p {font-size: 100%}
p.body {
padding: 4px; 
margin: 4px;
}
h1 {font-size: 130%}
h1 {color: #000099}
table.tools {
border:2px solid;
width: 98%;
border-top-color: #E6E6E6;
border-bottom-color: #000099;
border-right-color: #000099;
border-left-color: #CCCCCC;
font: 14px Verdana, Arial, Helvetica, sans-serif
}
td {
color: #000099;
font: 14px Verdana, Geneva, Arial, Helvetica, sans-serif;
border-color: #000099;
}
td {vertical-align:middle}
td.button {
width: 212px;
padding: 0px;
background-color: ##6699FF;
}
td.every {
background-color: white;
padding-left: 6px;
}
td.other {
background-color: #E5ECFF;
padding-left: 6px;
}
input.button {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: 14px;
background-color: #000099;
color: white;
width:211px;
height: 40px;
}
} 
.style2 {
    border-style: solid;
    border-width: 1px;
}
} 
.style2b {
    border-style: solid;
    border-width: 1px;
    background-color: #000099;
    color: white;
    padding-left: 6px;
}

</style>
<script language="VBScript">
Sub ServiceChecker_Onclick()
Dim strURL
Dim strNUM
Dim WshShell
Dim i
Set WshShell = CreateObject("WScript.Shell")
dim shomedrv, shomepath, spath
shomedrv=WshShell.expandenvironmentstrings("%homedrive%")
shomepath=WshShell.expandenvironmentstrings("%homepath%")
spath=shomedrv & shomepath & "\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
i = 1
if i=strNUM Then
  alert("all Done")
Else
  WshShell.Run chr(34) & spath & chr(34) & Space(1) & strURL
  i = i + 1
End If
End Sub

Sub strNUM
Dim strNum
Dim formURL  
strNUM = formNUM
End Sub

Sub strURL
Dim strURL
Dim formURL 
strURL = formURL
End Sub

</script>
</head>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 400,400
    End Sub 
</SCRIPT>

<body>
<div>
<table class="tools" cellspacing="0">
<tr>
<td class="button">

<form name="NUM" >
number of tabs: <input type="text" name="formNUM" value="" onchange="strNUM()" >
</form>

<form name="URL" >
tab URL: <input type="text" name="formURL" value="" onchange="strURL()" >
</form>

<form name="formHTA" >
<input type="button" value="Submit" onclick="ServiceChecker_Onclick()" >
</form>

</td>
<td class="other"></td>
</tr>
</table>
</div>
<br>
<br>
</body>

[!]The AutoSavers![/!] [2thumbsup]
 
[2] Why all the function/sub and all the variable names colliding all over the places? The lexical space for the naming is so vaste that there is no reason for allowing that to happen.

[2.1] The main thing say in the ServiceChecker_OnClick, if you dim StrNum, it is not calling a function of whatever...
 
[3] And then i=i+1 is inside if-then-end if! do you mean to do a loop on i?
 
Sorry tsuji - I'm struggling quite a bit. The i variable is supposed to cause a loop until it's value equals the strNUM at which point to loop should end. I have now tried changing the text fields to onblur and the script that SHOULD assign their values to javascript. I have even added some alert events to the ServiceChecker_OnClick script to show me the values of the strURL and strNUM variables. These are coming up empty.

This is so frustrating!

Code:
<head>
<title>test app</title>
<HTA:APPLICATION 
     APPLICATIONNAME="test app"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<style type="text/css">
body { 
font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color:#CCCCCC; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6699FF',EndColorStr='#FFFFFF');

p {font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif}
p {color: black}
p {font-size: 100%}
p.body {
padding: 4px; 
margin: 4px;
}
h1 {font-size: 130%}
h1 {color: #000099}
table.tools {
border:2px solid;
width: 98%;
border-top-color: #E6E6E6;
border-bottom-color: #000099;
border-right-color: #000099;
border-left-color: #CCCCCC;
font: 14px Verdana, Arial, Helvetica, sans-serif
}
td {
color: #000099;
font: 14px Verdana, Geneva, Arial, Helvetica, sans-serif;
border-color: #000099;
}
td {vertical-align:middle}
td.button {
width: 212px;
padding: 0px;
background-color: ##6699FF;
}
td.every {
background-color: white;
padding-left: 6px;
}
td.other {
background-color: #E5ECFF;
padding-left: 6px;
}
input.button {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: 14px;
background-color: #000099;
color: white;
width:211px;
height: 40px;
}
} 
.style2 {
    border-style: solid;
    border-width: 1px;
}
} 
.style2b {
    border-style: solid;
    border-width: 1px;
    background-color: #000099;
    color: white;
    padding-left: 6px;
}

</style>
<script language="VBScript">
Sub ServiceChecker_Onclick()
Dim strURL
Dim strNUM
Dim WshShell
Dim i
Set WshShell = CreateObject("WScript.Shell")
dim shomedrv, shomepath, spath
shomedrv=WshShell.expandenvironmentstrings("%homedrive%")
shomepath=WshShell.expandenvironmentstrings("%homepath%")
spath=shomedrv & shomepath & "\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
i = 0
if i=strNUM Then
  alert("all Done")
  alert(strURL & "url")
  alert(strNUM & "tabs")
Else
  WshShell.Run chr(34) & spath & chr(34) & Space(1) & strURL
  i = i + 1
End If
End Sub
</script>
<script type="text/javascript">
function strNUM()
{
var strNUM=document.getElementById("formNUM").value
}
</script>
<script type="text/javascript">
function strURL()
{
var strURL=document.getElementById("formURL").value
}
</script>
</script>
</head>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 400,400
    End Sub 
</SCRIPT>

<body>
<div>
<table class="tools" cellspacing="0">
<tr>
<td class="button">

number of tabs: <input type="text" id="formNUM" onblur="strNUM()" >

tab URL: <input type="text" id="formURL" onblur="strURL()" >

<form name="formHTA" >
<input type="button" value="Submit" onclick="ServiceChecker_Onclick()" >
</form>

</td>
<td class="other"></td>
</tr>
</table>
</div>
<br>
<br>
</body>

[!]The AutoSavers![/!] [2thumbsup]
 
[2.2] You don't get it, do you?
[tt]
Dim strNUM
if i=strNUM Then
'etc
end if

Sub strNUM
Dim strNum
'etc etc
End Sub
[/tt]
Why all these kinds of collision? Do you think strNum will be evaluated by the sub? Also, once you dim it, it won't be recognized as a sub. And a sub won't return a number, and that number inside the sub strNum will never get global (scope)... That is a terrible mess. Don't change anything to javascript to get excuses...
 
ok tsuji - this does what I want to now but, I am concerned my code is sloppy by what you have said. I have a added a line for the ping command to the loop to "sleep" for a few seconds. This now works but, please let me know what you think might need improving. Thank you very much for all your help!
Code:
<head>
<title>test app</title>
<HTA:APPLICATION 
     APPLICATIONNAME="test app"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<style type="text/css">
body { 
font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color:#CCCCCC; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6699FF',EndColorStr='#FFFFFF');

p {font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif}
p {color: black}
p {font-size: 100%}
p.body {
padding: 4px; 
margin: 4px;
}
h1 {font-size: 130%}
h1 {color: #000099}
table.tools {
border:2px solid;
width: 98%;
border-top-color: #E6E6E6;
border-bottom-color: #000099;
border-right-color: #000099;
border-left-color: #CCCCCC;
font: 14px Verdana, Arial, Helvetica, sans-serif
}
td {
color: #000099;
font: 14px Verdana, Geneva, Arial, Helvetica, sans-serif;
border-color: #000099;
}
td {vertical-align:middle}
td.button {
width: 212px;
padding: 0px;
background-color: ##6699FF;
}
td.every {
background-color: white;
padding-left: 6px;
}
td.other {
background-color: #E5ECFF;
padding-left: 6px;
}
input.button {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: 14px;
background-color: #000099;
color: white;
width:211px;
height: 40px;
}
} 
.style2 {
    border-style: solid;
    border-width: 1px;
}
} 
.style2b {
    border-style: solid;
    border-width: 1px;
    background-color: #000099;
    color: white;
    padding-left: 6px;
}

</style>
<script language="VBScript">
Sub ServiceChecker_Onclick()
Dim WshShell
Dim i
Set WshShell = CreateObject("WScript.Shell")
dim shomedrv, shomepath, spath, strCmd
shomedrv=WshShell.expandenvironmentstrings("%homedrive%")
shomepath=WshShell.expandenvironmentstrings("%homepath%")
spath=shomedrv & shomepath & "\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
i = strNum
Do Until i=0
  i=i-1
  WshShell.Run chr(34) & spath & chr(34) & Space(1) & strURL
  strCmd = "%COMSPEC% /c ping -n " & 10 & " 127.0.0.1>nul"
  WshShell.Run strCmd,0,1
  If i<1 Then Exit Do
Loop
End Sub
</script>

<script type="text/javascript">
function strNUM()
{
strNUM=document.getElementById("formNUM").value
}
</script>

<script type="text/javascript">
function strURL()
{
strURL=document.getElementById("formURL").value
}
</script>

</script>
</head>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 400,400
    End Sub 
</SCRIPT>

<body>
<div>
<table class="tools" cellspacing="0">
<tr>
<td class="button">

number of tabs: <input type="text" id="formNUM" onblur="strNUM()" >

tab URL: <input type="text" id="formURL" onblur="strURL()" >

<form name="formHTA" >
<input type="button" value="Submit" onclick="ServiceChecker_Onclick()" >
</form>

</td>
<td class="other"></td>
</tr>
</table>
</div>
<br>
<br>
</body>

[!]The AutoSavers![/!] [2thumbsup]
 
It is really difficult for anyone to help you with this script as it is. Among the many things wrong, tsuji has tried several times to point out that you have Subs and Functions and variables all sharing the exact same name!

This shows that you do not understand what subs, functions, and/or variables are, so please read the links below for a quick primer:

Once you grasp these concepts, the next step would be to NOT use any conflicting names. Subs, Functions, and variables should never share the same name. Then, perhaps you can get help on the rest.

cbsarge said:
this does what I want to now but...
Really??
 
... and once you understand what a sub / function is... you have "onblur" events associated with your textboxes, which calls some subroutine. You have to ask yourself, what do I want this subroutine to do? And is this even necessary at all?
 
It's me again! I'm trying to add a radio button to this that will let me choose the browser that the tabs open in. The version below won't let me actually choose one of the radio buttons. Can someone tell me what is preventing me from picking a radio button?
Code:
<head>
<title>Multi-Tab Tool</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Multi-Tab Tool"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<style type="text/css">
body { 
font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color:#CCCCCC; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6699FF',EndColorStr='#FFFFFF');
p {font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif}
p {color: black}
p {font-size: 100%}
p.body {
padding: 4px; 
margin: 4px;
}
</style>
<script language="VBScript">
Sub Multi_Tab()
Dim WshShell
Dim i
dim shomedrv, shomepath, spath, strCmd
Set WshShell = CreateObject("WScript.Shell")
shomedrv=WshShell.expandenvironmentstrings("%homedrive%")
shomepath=WshShell.expandenvironmentstrings("%homepath%")
spath=varBrowser
i=varNum
Do Until i=0
  i=i-1
  WshShell.Run chr(34) & spath & chr(34) & Space(1) & varURL
  strCmd = "%COMSPEC% /c ping -n " & 5 & " 127.0.0.1>nul"
  WshShell.Run strCmd,0,1
  If i<1 Then Exit Do
Loop
varURL=""
varNUM=""
varBrowser=""
End Sub
</script>

<script type="text/javascript">
function strNUM()
{
if(document.getElementById("formNUM").value == "")
{
alert("You left the number field blank!");
}
else
{
varNUM=document.getElementById("formNUM").value;
}
}
</script>

<script type="text/javascript">
function strURL()
{
if(document.getElementById("formURL").value == "")
{
alert("You left the URL field blank!");
}
else
{
varURL=document.getElementById("formURL").value
}
}
</script>

<script type="text/javascript">
function strBrowser()
{
if(document.getElementById("formBrowser").value == "")
{
varBrowser="chrome.exe";
}
else
{
varBrowser=document.getElementById("formBrowser").value
}
}
</script>

<script type="text/javascript">
function refresh()
{
window.location.reload(true);
}
</script>
</head>

<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 360,360
    End Sub 
</script>
<body>
<div align="center" style="width:310px; height:330px">
<strong>Multi-Tab Tool</strong></font>
<br><hr>
<p align="middle">
# of tabs:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tab URL:<br>
<input type="text" size="12" id="formNUM" onblur="strNUM()" >&nbsp;&nbsp;
<input type="text" size="12" id="formURL" onblur="strURL()" >
<br><br></p>
<p align="middle">
<form name="formHTA" >
<input type="button" value="Submit Tabs" onclick="Multi_Tab()" >
<input type="button" value="Clear Fields" onclick="refresh()" >
</form></p>
<hr>
Browser:<br>
<input type="radio" id="formBrowser" value="chrome.exe" onclick="strBrowser()" >Chrome
<input type="radio" id="formBrowser" value="iexplore.exe" onclick="strBrowser()" >Internet Explorer
<input type="radio" id="formBrowser" value="firefox.exe" onclick="strBrowser()" >Firefox<br><br>
Use the Refresh button to clear the text boxes.<br><br><hr>
Final Judgement's Multi Tab Tool creates a<br>defined number of tabs in your browser.
</div>
</body>

[!]The AutoSavers![/!] [2thumbsup]
 
Before you go any further, I STRONGLY RECOMMEND that you rename your subs and functions to reflect their purpose.

Furthermore, the naming convention you currently use for sub/function names is commonly used to indicate a variables data type. When I see strBrowser, I interpret it as a variable named "Browser" with a data type of "string". When I see intCount, I interpret it as a variable name "Count" with a data type of "integer".

Your code is "sloppy" because it lacks readablity. Throw some tabs, spaces and line-breaks (enter) in there to make it easier to read. Example
Code:
Sub Multi_Tab()
   Dim WshShell
   Dim idim shomedrv, shomepath, spath, strCmd

   Set WshShell = CreateObject("WScript.Shell")
   shomedrv = WshShell.expandenvironmentstrings("%homedrive%"
   shomepath = WshShell.expandenvironmentstrings("%homepath%")
   spath = varBrowser
   i = varNum

   Do Until (i = 0)
      i = i - 1
      WshShell.Run chr(34) & spath & chr(34) & Space(1) & varURL
      strCmd = "%COMSPEC% /c ping -n " & 5 & " 127.0.0.1>nul"
      WshShell.Run strCmd, 0, 1
      If (i < 1) Then
         Exit Do
      End If
   Loop

   varURL = ""
   varNUM = ""
   varBrowser = ""
End Sub

Another suggestion is tho put all your non-HTML (javascript/vbs/CSS) in it's own file and include it at the <head> or your HTA. Example
Code:
<script language="JavaScript" src="javaFunctions.js"></script>
<script language="VBScript" src="vbsFunctions.vbs"></script>
<link rel="stylesheet" href="styles.css" type="text/css">

Once that's complete, we can talk about radio buttons :)

-Geates

NOTE: Understand that it can be extremely difficult to help if people can't understand what they're are looking at. Also, realize the quote in my signature isn't just for a laugh. You'll have greater success developing applications if you take it's concept to heart.

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding
 
Thank you for the critique! Boy, I get called on for sloppy code a lot!

I'll have to see if I can follow more conventional forms of naming variables in the future. Up to now I have just used naming that made sense to me but, I guess if I am going to ask programmers for help I should learn to follow more conventional methods.

I got the radio button to work.
Code:
<head>
<title>Multi-Tab Tool</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Multi-Tab Tool"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<style type="text/css">
body { 
font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color:#CCCCCC; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6699FF',EndColorStr='#FFFFFF');
p {font: 12px Verdana, Geneva, Arial, Helvetica, sans-serif}
p {color: black}
p {font-size: 100%}
p.body {
padding: 4px; 
margin: 4px;
}
</style>
<script language="VBScript">
Sub Multi_Tab()
Dim WshShell
Dim i
dim shomedrv, shomepath, spath, strCmd
Set WshShell = CreateObject("WScript.Shell")
shomedrv=WshShell.expandenvironmentstrings("%homedrive%")
shomepath=WshShell.expandenvironmentstrings("%homepath%")
spath=varBrowser
i=varNum
Do Until i=0
  i=i-1
  WshShell.Run chr(34) & spath & chr(34) & Space(1) & varURL
  strCmd = "%COMSPEC% /c ping -n " & 5 & " 127.0.0.1>nul"
  WshShell.Run strCmd,0,1
  If i<1 Then Exit Do
Loop
varURL=""
varNUM=""
varBrowser=""
End Sub
</script>

<script type="text/javascript">
function strNUM()
{
if(document.getElementById("formNUM").value == "")
{
alert("You left the number field blank!");
}
else
{
varNUM=document.getElementById("formNUM").value;
}
}
</script>

<script type="text/javascript">
function strURL()
{
if(document.getElementById("formURL").value == "")
{
alert("You left the URL field blank!");
}
else
{
varURL=document.getElementById("formURL").value
}
}
</script>

<script type="text/javascript">
function strBrowser() {
var radioButtons = document.getElementsByName("formBrowser");
for (var x = 0; x < radioButtons.length; x ++) {
if (radioButtons[x].checked) {
varBrowser=radioButtons[x].id;
}
}
}
</script>

<script type="text/javascript">
function refresh()
{
window.location.reload(true);
}
</script>
</head>

<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 360,360
    End Sub 
</script>
<body>
<div align="center" style="width:310px; height:330px">
<strong>Multi-Tab Tool</strong></font>
<br><hr>
<p align="middle">
# of tabs:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tab URL:<br>
<input type="text" size="12" id="formNUM" onblur="strNUM()" >&nbsp;&nbsp;
<input type="text" size="12" id="formURL" onblur="strURL()" >
<br><br></p>
<p align="middle">
<form name="formHTA" >
<input type="button" value="Submit Tabs" onclick="Multi_Tab()" >
<input type="button" value="Clear Fields" onclick="refresh()" >
</form></p>
<hr>
Browser:<br>
<input type="radio" name="formBrowser" id="chrome.exe" value="chrome.exe" onclick="strBrowser()" >Chrome
<input type="radio" name="formBrowser" id="iexplore.exe" value="iexplore.exe" onclick="strBrowser()" >Internet Explorer
<input type="radio" name="formBrowser" id="firefox.exe" value="firefox.exe" onclick="strBrowser()" >Firefox<br><br>
Use the Refresh button to clear the text boxes.<br><br><hr>
Final Judgement's Multi Tab Tool creates a<br>defined number of tabs in your browser.
</div>
</body>

[!]The AutoSavers![/!] [2thumbsup]
 
And I fixed the rest.

It's not necessarily what others would do, but the formatting follows general guidelines. Learn from it!

It's amazing how many error you can see when code has readability. Also, there is no point to posting your ENTIRE code when you only changed 1 line - it give anxiety.

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top