View Single Post
Old 05-26-2008   #3 (permalink)
Daz


 
 

Re: vbscript and HTA help

On May 25, 10:33*am, "McKirahan" <N...@xxxxxx> wrote:
Quote:

> "Daz" <darren.black...@xxxxxx> wrote in message
>
> news:83da94f4-28e4-46de-9eea-0fc83ac03dee@xxxxxx
>
>
>
Quote:

> > Hi all,
>
Quote:

> > Am trying my hand at my first HTA and would like to ask for some help
> > with a process i am tying to implement...
>
Quote:

> > I would like to select one option of 3 options for a given object and
> > then once all the objects have had a selection, output the object.name
> > to a text file maching the choice... so if i picked disable for object
> > 1 and automatic for object 2 and manual for object 3 and automatic for
> > object 4 - i would have 3 text files with the object name on a line.
> > So the output file for automatic (lets call it automatic.txt) would
> > have object1 and on the next line object4.
>
Quote:

> > I think you get what i mean....
>
Quote:

> > here is the test hta code i am working with at the moment...
>
> [snip]
>
> Will this help? *Watch for word-wrap.
>
> <html>
> <head>
> <title>test</title>
> <hta:application
> *ID="objHTA"
> *VERSION="1.0"
> *icon="simple.ico"
> *applicationName="test"
> *border=dialog
> *borderStyle=normal
> *caption=yes
> *contextMenu=yes
> *innerBorder=yes
> *maximizeButton=yes
> *minimizeButton=yes
> *navigable=yes
> *scroll=no
> *selection=yes
> *showInTaskBar=yes
> *singleInstance=yes
> *sysMenu=yes
> *windowState=normal
> />
> <script language="vbscript">
> Sub Radios()
> * * Const cMAX = 4
> * * Dim arrCTF(3)
> * * Dim intCTF
> * * Dim strCTF
> * * Dim arrDIC(3)
> * * * * arrDIC(1) = "Automatic"
> * * * * arrDIC(2) = "Disable"
> * * * * arrDIC(3) = "Manual"
> * * Dim intDIC
> * * Set objDIC = CreateObject("Scripting.Dictionary")
> * * For intDIC = 1 To UBound(arrDIC)
> * * * * objDIC.Add arrDIC(intDIC), intDIC
> * * Next
> * * Dim iMAX : iMAX = 0
> * * DIm i, o, s
> * * For i = 1 To cMAX
> * * * * For Each o In Eval("document.form1.object" & i)
> * * * * * * If o.Checked = True Then
> * * * * * * * * iMAX = iMAX + 1
> * * * * * * * * intCTF = objDIC.Item(o.Value)
> * * * * * * * * arrCTF(intCTF) = arrCTF(intCTF) & "object" & i & vbCrLf
> * * * * * * End If
> * * * * Next
> * * Next
> * *'*
> * * If iMAX = cMAX Then
> * * * * Set objFSO = CreateObject("Scripting.FileSystemObject")
> * * * * For intDIC = 1 To UBound(arrDIC)
> * * * * * * strCTF = arrDIC(intDIC) & ".txt"
> * * * * * * Set objCTF = objFSO.CreateTextFile(strCTF,True)
> * * * * * * * * objCTF.Write arrCTF(intDIC)
> * * * * * * Set objCTF = Nothing
> * * * * * * s = s & "<li>" & strCTF & " : " &
> Replace(arrCTF(intDIC),vbCrLf," ") & vbCrLf
> * * * * Next
> * * Else
> * * * * Alert("Only " & iMAx & " of " & cMAX & " radio buttons checked!")
> * * * * Exit Sub
> * * End If
> * *'*
> * * document.write s
> End Sub
>
> Sub Window_Onload()
> * * Const strComputer = "."
> * * Set objWMIService = GetObject("winmgmts:\\" & strComputer &
> "\root\cimv2")
> * * Set colItems = objWMIService.ExecQuery("Select * From
> Win32_DesktopMonitor")
> * * For Each objItem in colItems
> * * * * intHorizontal = objItem.ScreenWidth
> * * * * intVertical = objItem.ScreenHeight
> * * Next
> * * intLeft = (intHorizontal - 800) / 2
> * * intTop = (intVertical - 600) / 2
> * * window.resizeTo 800,600
> * * window.moveTo intLeft, intTop
> * * window.focus()
> End Sub
> </script>
> </head>
> <body>
> <form name="form1">
> <table border="1" width="300">
> <tr>
> * <td>object 1</td>
> </tr>
> <tr>
> * <td>
> * * <input type="radio" name="object1" value="Disable">Disable
> * * <input type="radio" name="object1" value="Automatic">Automatic
> * * <input type="radio" name="object1" value="Manual">Manual
> * </td>
> </tr>
> <tr>
> * <td>object 2</td>
> </tr>
> <tr>
> * <td>
> * * <input type="radio" name="object2" value="Disable">Disable
> * * <input type="radio" name="object2" value="Automatic">Automatic
> * * <input type="radio" name="object2" value="Manual">Manual
> * </td>
> </tr>
> <tr>
> * <td>object 3</td>
> </tr>
> <tr>
> * <td>
> * * <input type="radio" name="object3" value="Disable">Disable
> * * <input type="radio" name="object3" value="Automatic">Automatic
> * * <input type="radio" name="object3" value="Manual">Manual
> * </td>
> </tr>
> <tr>
> * <td>object 4</td>
> </tr>
> <tr>
> * <td>
> * * <input type="radio" name="object4" value="Disable">Disable
> * * <input type="radio" name="object4" value="Automatic">Automatic
> * * <input type="radio" name="object4" value="Manual">Manual
> * </td>
> </tr>
> </table>
> <br>
> <input type="button" value="Submit" onclick="Radios()">
> <input type="reset" value="Reset" >
> </form>
> </body>
> </html>
Hi,

Thanks for you help and the code... it certainly is the sort of thing
i am looking for. The only issue i have at the moment is that the
output from the selected options isn't being captured in the txt files
- am i missing something?

Cheers,
Daz
My System SpecsSystem Spec