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 08-13-2016, 04:28 PM
ZeroAssassin ZeroAssassin is offline
Registered User
 
Join Date: Aug 2016
Posts: 6
Text input hit and miss with forms in IE

I've recently been learning how to script again once obtaining SecureCRT for work. I recently used the username and password template in the scripting essentials portion for: Building Custom Dialogs or Forms. Everything in the script works great, but when I am typing into the IE text boxes for the text, it's hit or miss if the text is registered into the text box. I use IE all the time for work and don't have an issue with this other then for this script.

I am using IE 11 and have Windows 7. Has there been any known issues of this similar to mine? Thanks!
Reply With Quote
  #2  
Old 08-15-2016, 08:17 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,937
Hi ZeroAssassin,

What do you mean by hit or miss?

Is it a focus issue with the IE dialog?

Have you altered the original script from the Scripting Essentials guide?

If so, in what way?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 08-15-2016, 01:20 PM
ZeroAssassin ZeroAssassin is offline
Registered User
 
Join Date: Aug 2016
Posts: 6
Hi Brenda,

What I mean by hit or miss is, when I am typing in the box, it will sometimes type what I am inputting and sometimes it won't. For example, if I'm typing an IP address or an interface for a router, it will sometimes miss a number or a slash when typing it. I figured it was either key presses being missed on my laptop or keyboard at work, but then it was becoming extremely frequent with just in the script. I changed the max length to 50 and seems like that might be helping a little bit.
Reply With Quote
  #4  
Old 08-15-2016, 01:23 PM
ZeroAssassin ZeroAssassin is offline
Registered User
 
Join Date: Aug 2016
Posts: 6
I've shortend the script a tad to be able to post, but it was just other data patterns in it, shouldn't be the cause of it though.

Code:
# $language = "VBScript"
# $interface = "1.0"
'Forms for Ping.vbs'

'Get a reference to IE's Application object'
Set g_objIE = CreateObject("InternetExplorer.Application")
g_objIE.Offline = False
g_objIE.navigate "about:blank"

Do
 crt.Sleep 100
Loop While g_objIE.Busy

g_objIE.Document.body.Style.FontFamily = "Sans-Serif"
strHTMLBody = _
 "<font color=red><b>Specify settings below for ping tests:</b></font>" & _
 "<hr>" & _
 "<b>Interface.......................................:</b>" & _
 "<input name=Interface size=25 maxlength=50 >" & _
 "<b><br />Clear counters on interface?.....:</b>" & _
"<input name=Counters size=25 maxlength=50 ><br />" & _
 "<b>VRF...............................................:</b>" & _
 "<input name=VRF size=25 maxlength=50 ><br />" & _
 "<b>IP address to ping.......................:</b>" & _
 "<input name=TargetIP size=25 maxlength=50 ><br />" & _
 "<b>Packets to send...........................:</b>" & _
 "<input name=RepeatCount size=25 maxlength=50 ><br />" & _
 "<b>Datagram Size(default size 100):</b>" & _
 "<input name=Datagram size=25 maxlength=50 ><br />" & _
 "<hr>" & _
 "<button name=OK AccessKey=O " & _
	"Onclick=document.all(""ButtonHandler"").value=""OK"";" & _
	"><u>O</u>K </button>" & _
 "&nbsp;&nbsp;&nbsp;&nbsp;" & _
 "<button name=Cancel AccessKey=C " & _
	"Onclick=document.all(""ButtonHandler"").value=""Cancel"";" & _
	"><u>C</u>ancel</button>" & _
"<input name=ButtonHandler value=""Nothing Clicked Yet"" " & _
	"type=hidden >"
'Injecting HTML code above into the IE object'
g_objIE.Document.Body.innerHTML = strHTMLBody
'Prevent the MenuBar, StatusBar, AddressBar, and Toolbar from being displayed'
g_objIE.MenuBar = False
g_objIE.StatusBar = False
g_objIE.AddressBar = False
g_objIE.Toolbar = False
'Seting the initial size of the IE window'
g_objIE.height = 260
g_objIE.width = 500
'Setting the title of the IE window'
g_objIE.document.Title = "Form for full pattern ping tests"
g_objIE.Visible = True
Do
 crt.Sleep 100
Loop While g_objIE.Busy
'This code brings the IE window to the foreground'
Set objShell = CreateObject("WScript.Shell")
objShell.AppActivate g_objIE.document.Title
'Once the dialog is displayed and has been brought to the'
'foreground, set focus on the control of our choice...'
g_objIE.Document.All("Interface").Focus
Do
 'Checking to see if alt-F4'd or the box has been force closed'
 On Error Resume Next
 Err.Clear
 strNothing = g_objIE.Document.All("ButtonHandler").Value
 if Err.Number <> 0 then exit do
 On Error Goto 0
 'Check to see which buttons have been clicked'
 Select Case g_objIE.Document.All("ButtonHandler").Value
 Case "Cancel"
 'The user clicked Cancel. Exiting the loop'
 g_objIE.quit
 Exit Do
 
 'Will start proceeding with the script'
 Case "OK"
 'OK was clicked and now storing all the information in the diaglog boxes'
	strInterface = g_objIE.Document.All("Interface").Value
	strClearCounters = g_objIE.Document.All("Counters").Value
	strVRF = g_objIE.Document.All("VRF").Value
	strTargetIP = g_objIE.Document.All("TargetIP").Value
	strRepeatCount = g_objIE.Document.All("RepeatCount").Value
	strDatagram = g_objIE.Document.All("Datagram").Value
	g_objIE.quit
	crt.Screen.Send "" &chr(13)
	
'Checking to see if we're in a CSR router'
	crt.Screen.WaitforString("#")
	strCRSCheck = crt.Screen.Get(39,18,39,20)
	
'Checking if we are clearing counters'
		if strInterface = "" then strClearCounters = ""
			if strClearCounters = "y" then crt.Screen.Send "clear counters " & strInterface & "" & chr(13) & chr(13)
	
'Checking to see which variation of ping to use'
	If strVRF = "" then 
		strStart = "ping" 
		Else 
		strStart = "ping vrf " & strVRF & ""
	End If
	
'Inputting all parameters for testing'
	crt.Screen.Send "" & strStart & "" & chr(13)
	crt.Screen.Send "" & chr(13) 'Protocol [ipv4]'
	crt.Screen.Send "" & strTargetIP & "" & chr(13) 'Target IP address'
	crt.Screen.Send "" & strRepeatCount & "" & chr(13) 'Repeat count'
	crt.Screen.Send "" & strDatagram & "" & chr(13) 'Datagram size'
	crt.Screen.Send "" & chr(13) 'Timeout in seconds'
'If this is a CSR, it will input an enter for the next command'	
		If strCRSCheck = "crs" Then
			crt.Screen.Send "" & chr(13)
		End If
'Should continue like normal afterwards'
	crt.Screen.Send "y" & chr(13) 'Extended commands'
	crt.Screen.Send "" & chr(13) 'Source address or interface'
	crt.Screen.Send "" & chr(13) 'Type of service [0]'
	crt.Screen.Send "" & chr(13) 'Set DF bit in IP header'
	crt.Screen.Send "" & chr(13) 'Validate reply data'
	crt.Screen.Send "0xABCD" & chr(13) 'Data pattern'
	crt.Screen.Send "" & chr(13) 'Loose, Strict, Record, Timestamp, Verbose'
	crt.Screen.Send "" & chr(13) 'Sweep range of sizes'
	
'End of setting parameters for the test; pending complete to run next pattern'

crt.Screen.WaitforString "Success rate"

'Start running all zeros (0x0000) data pattern for options above'

	crt.Screen.Send "" & strStart & "" & chr(13)
	crt.Screen.Send "" & chr(13) 'Protocol [ipv4]'
	crt.Screen.Send "" & strTargetIP & "" & chr(13) 'Target IP address'
	crt.Screen.Send "" & strRepeatCount & "" & chr(13) 'Repeat count'
	crt.Screen.Send "" & strDatagram & "" & chr(13) 'Datagram size'
	crt.Screen.Send "" & chr(13) 'Timeout in seconds'
'If this is a CSR, it will input an enter for the next command'	
		If strCRSCheck = "crs" Then
			crt.Screen.Send "" & chr(13)
		End If
'Should continue like normal afterwards'
	crt.Screen.Send "y" & chr(13) 'Extended commands'
	crt.Screen.Send "" & chr(13) 'Source address or interface'
	crt.Screen.Send "" & chr(13) 'Type of service [0]'
	crt.Screen.Send "" & chr(13) 'Set DF bit in IP header'
	crt.Screen.Send "" & chr(13) 'Validate reply data'
	crt.Screen.Send "0x0000" & chr(13) 'Data pattern'
	crt.Screen.Send "" & chr(13) 'Loose, Strict, Record, Timestamp, Verbose'
	crt.Screen.Send "" & chr(13) 'Sweep range of sizes'
	
'End of setting parameters for the test; pending complete to run next pattern'

crt.Screen.WaitforString "Success rate"

'Start running all ones (0xFFFF) data pattern for options above'

	crt.Screen.Send "" & strStart & "" & chr(13)
	crt.Screen.Send "" & chr(13) 'Protocol [ipv4]'
	crt.Screen.Send "" & strTargetIP & "" & chr(13) 'Target IP address'
	crt.Screen.Send "" & strRepeatCount & "" & chr(13) 'Repeat count'
	crt.Screen.Send "" & strDatagram & "" & chr(13) 'Datagram size'
	crt.Screen.Send "" & chr(13) 'Timeout in seconds'
'If this is a CSR, it will input an enter for the next command'	
		If strCRSCheck = "crs" Then
			crt.Screen.Send "" & chr(13)
		End If
'Should continue like normal afterwards'
	crt.Screen.Send "y" & chr(13) 'Extended commands'
	crt.Screen.Send "" & chr(13) 'Source address or interface'
	crt.Screen.Send "" & chr(13) 'Type of service [0]'
	crt.Screen.Send "" & chr(13) 'Set DF bit in IP header'
	crt.Screen.Send "" & chr(13) 'Validate reply data'
	crt.Screen.Send "0xFFFF" & chr(13) 'Data pattern'
	crt.Screen.Send "" & chr(13) 'Loose, Strict, Record, Timestamp, Verbose'
	crt.Screen.Send "" & chr(13) 'Sweep range of sizes'

	
'End of data pattern, end of running ping patterns'

crt.Screen.WaitforString "Success rate"

'Doing a show interface at end if an interface was configured'

	If strInterface = "" Then 
		exit do
	Else
		crt.Screen.Send "show interface " & strInterface & "" & chr(13)
	End If
	Exit Do
End Select
Loop
Reply With Quote
  #5  
Old 08-15-2016, 01:32 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,937
Hi ZeroAsssassin,

Quote:
I figured it was either key presses being missed on my laptop or keyboard at work, but then it was becoming extremely frequent with just in the script. I changed the max length to 50 and seems like that might be helping a little bit.
I am not sure which value of 50 you are referencing, but the script author did suggest you might need to adjust the sleep value as that can cause your key presses to be missed, as you suggested.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #6  
Old 08-16-2016, 06:11 PM
ZeroAssassin ZeroAssassin is offline
Registered User
 
Join Date: Aug 2016
Posts: 6
Hi Brenda, which sleep value and should I increase it or decrease it? I've commented both of the sleeps out and I still have the same trouble. I've also changed the sleep timers up to 1000 and lowered them as low as 10 and still experiencing the same issue. Thanks for your help on this.
Reply With Quote
  #7  
Old 08-17-2016, 11:14 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,937
Hi ZeroAssassin,

Your script has changed quite a bit from the original in the Scripting Essentials guide. There were actually *three* sleep commands in the original version of the script. You appear to have removed the third one, which was just before the Loop end. See attached.

You may not need to adjust the timing at all, just put the sleep call back in.
Attached Images
File Type: png MissingSleepForUserInput.png (193.7 KB, 224 views)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #8  
Old 08-17-2016, 09:51 PM
ZeroAssassin ZeroAssassin is offline
Registered User
 
Join Date: Aug 2016
Posts: 6
Brenda,

Thank you for your help on this! I am seeing the missing sleep at the end of the script and has been placed in there and has resolved the trouble! Thank you so much for your help on this. Have a great day!
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 12:15 PM.