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!

VBS / IE intrface ??

Status
Not open for further replies.

DANZIG

Technical User
Mar 8, 2001
142
US
Hello,
I'm trying to write a script that generates html streams and send them to an instance of IE ( no real html file exists ). The problem I'm running in to is getting the html form input back from IE to the hosting vbs script to proccess the users input. I've seen the alert method [ alert Document.myForm.myText.Value ] not seem to reference that name space through the parent vbs script.

Set objDoc = MSIE.Document.myForm.myText.Value
Wscript.Echo ojbDoc

It seems that there would be an easy way to pull the user inputs back out of IE to return the variant value back to the host vbs session with out using java or having an external file ( beyond the vbs script that is creating the IE and the html stream being sent to IE for the users input ), but I can't seem to locate one. Even the msgbox method will not work if it is not being supplied via an actual html file ( doesn't work via an html stream via the host script ).

If anybody has a good exaple of how to achieve this it would be much appreciated. I would like to user the power of IE for a user interface in self contained scripts which are more geared towards admin work than webpages.

Thanks in advance.
 
If by "java" you mean javascript, disregard. Otherwise, have you tried a javascript variable in the URL?
 
Sorry that would limit the string length. A cookie could be much larger but still limited.
 
Most of my scripts are used for data mining in the domain that I support ( 2k users and a little over 2k systems ). I don't really script towards webpages at all, I'd just like to use the IE interface and forms to get away from the popup's and msgbox /inputbox interfaces that are normally used as they are limiting in what can be retrieved from and displayed to the user. I don't wish to get in to full blown VB to create a better interface, I'd just like to use the forms capability of the html streams to my advantage when scripting.

For example a simple blank html page with one textbox in it and a heading over it asking for a machine name, then taking the input from the textbox in the form and using it in the parent script to search for a particular directory on that system and upon it's existance display a \\uncbased\hyperlink back in the html interface for the user to browse that diectory on the targeted system. Doing all of that with no dependency html files as the vbs script would just send html streams to the IE enterface.

More or less I just want to use IE as a gui interface for domain / network admin scripts to by pass the limitations of the msgbox/inputbox/popup interfaces that are native to the script.

If anybody has anything similar to it, or an idea of how to do it that would be great.

Thanks in advance.
 
Check this site out:


The topics are advanced, but this is one of the best WSH resources I've found.

Once there, click on "Samples" Then Using forms in VBScript/JScript.

This should get you where you need to be.
 
Can this script help you?

Option Explicit
Dim oIE, doc1
On Error GOTO 0

' Create Internet Explorer Application Object.
Set oIE = WScript.CreateObject("InternetExplorer.Application")
oIE.Navigate "about:blank" ' Empty HTML document
oIE.Visible = 1 ' Internet Explorer is visible.
oIE.ToolBar = 0
oIE.StatusBar = 0
oIE.Width = 450
oIE.Height = 90

Do While (oIE.Busy): Loop ' Important: Wait until Internet
' Explorer Is ready.

Set doc1 = oIE.Document ' Get Document object.
doc1.open ' Open document.

doc1.writeln &quot;<html>&quot;
doc1.writeln &quot; <script language='VBScript'> &quot;
doc1.writeln &quot; <!-- &quot;
doc1.writeln &quot; Dim ready &quot;
doc1.writeln &quot; Sub butOK_OnClick &quot;
doc1.writeln &quot; ready = 1 ' User input is ready. &quot;
doc1.writeln &quot; End Sub &quot;
doc1.writeln &quot; Sub Window_OnLoad() &quot;
doc1.writeln &quot; ready = 0 ' User input not ready. &quot;
doc1.writeln &quot; End Sub &quot;
doc1.writeln &quot; Public Function CheckVal() &quot;
doc1.writeln &quot; CheckVal = ready &quot;
doc1.writeln &quot; End function &quot;
doc1.writeln &quot; '--> &quot;
doc1.writeln &quot; </script> &quot;
doc1.writeln &quot;<FORM name='MyForm'>&quot;
doc1.writeln &quot;Input Text: <INPUT TYPE=TEXT NAME='txtInput' VALUE='' SIZE=15>&quot;
doc1.writeln &quot;<INPUT TYPE=BUTTON NAME='butOK' VALUE=' OK '>&quot;
doc1.writeln &quot;</FORM>&quot;
doc1.writeln &quot;</body></html>&quot;

doc1.close ' Close document for write access.

' Wait until the user clicks the OK button.
' Use the CheckVal function.
On Error Resume Next ' Handle case in which IE is closed.
Do ' Wait until the OK button is clicked.
WScript.Sleep 200 ' Suspend for 0.2 seconds
Loop While (oIE.Document.Script.CheckVal() = 0)

' If an error occurs because the form is closed, quit the
' script.
If Err <> 0 Then
WScript.Quit ' End script.
End If

With oIE.Document.MyForm
msgBox &quot;txtInput Value: &quot; & .txtInput.Value
End With

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top