Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-18-2019, 11:33 AM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
Example using HTML web page for input

Code:
Sub HTMLtest
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objShell = CreateObject("WScript.Shell")
		On Error Resume Next
		Set objExplorer = CreateObject _
		    ("InternetExplorer.Application")
		objExplorer.Navigate "about:blank"
		objExplorer.ToolBar = 0
		objExplorer.StatusBar = 0
		objExplorer.Width = 500
		objExplorer.Height = 500
		objExplorer.Visible = 1             
		objExplorer.Document.Title = "HTMLform"
		On Error Goto 0

		objExplorer.Document.Body.InnerHTML = "<h2>User Options</h2><hr> " &_
			"" &_
			"<button name='Cancel'" &_ 
        	"style='background-color:slate; border-radius: 8px; padding: 2px; font-size: 12px; margin: 5px;'Onclick=document.all('ButtonHandler').value='Cancel'" &_
        	";><u>Cancel</u></button><br>" &_
			"" &_
			"<font color='red'><b><u>Ilabel</u></b>&nbsp;" & _
			"<input name='Ilabel' value ='DfValue' size='10' maxlength='512'><br>" &_
	    	"" &_
	    	"<font color='green'>" &_
	    	"<input type='radio' id='radio1' name='RadioB' value='Radio1'><label for='radio1'>Radio Button 1</label>" &_
	    	"" &_
	    	"<input type='radio' id='radio2' name='RadioB' value='Radio2'><label for='radio2'>Radio Button 2</label>" &_
	    	"" &_
	    	"<input type='radio' id='radio3' name='RadioB' value='Radio3'><label for='radio3'>Radio Button 3</label><br>" &_
	    	"" &_
		    "<Select name='Dropdown'>" &_
				"<option value='1op'>Option1</option>" &_
				"<option value='2op'>Option2</option>" &_
				"<option value='3op'>Option3</option>" &_
				"<option value='4op'>Option4</option>" &_
			"</select><br>" &_
	    	"<button name='Continue'" &_ 
        	"style='background-color:slate; border-radius: 8px; padding: 2px; font-size: 12px; margin: 5px;" &_
        	"'Onclick=document.all('ButtonHandler').value='Continue'" &_
        	";><u>Continue</u></button>&nbsp;" &_
	    	"" &_
	    	"<button name='Something'" &_ 
        	"style='background-color:slate; border-radius: 8px; padding: 2px; font-size: 12px; margin: 5px;" & _
        	"'Onclick=document.all('ButtonHandler').value='command_to_run'" &_
        	";><u>Something</u></button><br>" &_
	    	"" &_
			"<input name='ButtonHandler' type='hidden' value='Nothing Clicked Yet'>" 'Set buttonHandler at the end of your HTML
			
'			 add checked to the radio button if you want the radio button checked by defualt but must have more than one to uncheck
'			<input type='radio' name='RadioB' value='RBvalue' checked>
		Do
	    	crt.Sleep 100
		Loop While objExplorer.Busy
	Do
		On Error Resume Next
	    Err.Clear
	    Button = objExplorer.Document.All("ButtonHandler").Value ' This checks to see which button was pressed and returns the .Value for that button
	    If Err.Number <> 0 then
	        	Action = "CLOSE"
	        	exit Do
        End If
	    Select Case Button 
		    Case "Cancel"
		        Action = "Cancel"
	            objExplorer.Quit
	            Exit Do
		    Case "Nothing Clicked Yet"
		    	'Does nothing until a button is clicked
		    Case Else
		    	Action = Button
		    	'Iterate through radio buttons to see which is checked
		    	c = 0
			    For Each Radio In objExplorer.Document.All("RadioB")
			    	If objExplorer.Document.All("RadioB")(c).Checked Then Checked = objExplorer.Document.All("RadioB")(c).Value
			    	c = c + 1
			    Next
			    'Get input box value
			    InputV = objExplorer.Document.All("Ilabel").Value
			    'Get dropdown selection
			    Drop = objExplorer.Document.All("Dropdown").Value
		    	objExplorer.Quit
		    	Exit Do
	    End Select
	    On Error Goto 0
	Loop
	objExplorer.Quit
	MsgBox "Value of Button Pressed: " & Action & vbCr & "Text in input field: " &_
	 InputV & vbCr & "Radio Checked: " & Checked & vbCr & "Dropdown: " & Drop
End Sub
The only issue I have had is that I.E. needs to be open already before running as it seems to have issues when secureCRT tries to open the new window. I should have most types of input covered.
__________________
Version 6.7.3 (build 292)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:18 AM.