#1
|
|||
|
|||
Display clipboard data using internet explorer
Hi,
I need some assistance for achieving following goal- -->Ask user to copy the list of commands to be executed (working) -->Display those commands using message box & ask user for the confirmation.(working) The issue I'm facing is, when user copies the more then 50 or some commands, message box is not able to display all of them(may be due to limitation of message box length) & hence user is not getting VbYesNo prompt. So,I need to achieve using internet explorer object if someone can help me with that. |
#2
|
|||
|
|||
Hi kamal,
Thanks for the question. The scripting manual has some general information about how you can use the IE object and HTML to accomplish your goal in chapter 6.3. You can find the scripting manual at the following location: http://www.vandyke.com/support/tips/...ing/index.htmlPlease note that since I am not an HTML expert, the HTML part of your goal will need to be researched elsewhere unless there is someone in this community that can assist. |
#3
|
|||
|
|||
![]()
Hi,
Your response does not help much. :-( Can you suggest any other method to display text of more than 50 lines using message box like functionality? |
#4
|
|||
|
|||
Hi Kamal,
If you don't want to modify the example in the scripting manual to meet your needs, you could use multiple message boxes. One way to do this would be to split the data into an array and find out how many elements are in the array. Then you can message box a subset of elements that you know will fit until you have displayed all of the elements of the array. Does this sound like it might work for you? What version of SecureCRT are you using? |
#5
|
|||
|
|||
Example:
Hi,
I have secureCRT v 7.1.1. Here is the snippet from my script, where user is being prompt for confirmation of the commands he copied to clipboard, since, sometimes we have more than 50 commands to run, the messagebox does not display them all & hence no VbYesNo button. So if you could share the example to do the same using IE, I would appreciate it. Since I have gone through the tutorial you shared as well as other POSTs in the forum, but not able to find the same-to display clipboard content in IE. #$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True Sub Main If crt.Session.Connected Then crt.Session.Disconnect crt.Session.Connect "/SSH2 /L XXXX /PASSWORD XXXX" & "z.z.z.z" crt.Session.Config.SetOption "Color Scheme", "Traditional" 'Turn off logging before setting up our script's logging... If crt.Session.Logging Then crt.Session.Log False 'Prompt User whether he wish to generate separate log files or combined one If crt.Dialog.MessageBox("Do you wish to generate combine log file? " & _ vbCR & vbCR & "Press yes to continue, No to generete seperate log file" , "Logging Options:" , vbYesNo) = vbYes Then LogPrompt = True Else LogPrompt = False End If 'If Condition for Combined logging is true If LogPrompt = True Then crt.Session.LogFileName = "C:\Users\XXXX\Desktop\Logs\%Y-%M-%D--%h-%m-%s-Combined_Logs.txt" Crt.Session.LogUsingSessionOptions End If 'Read the commands to be executed from ClipBoard & if null throw error If Trim(crt.Clipboard.Text) = vbcrlf Then crt.Dialog.MessageBox "No text found in the Windows Clipboard." Exit Sub End If 'Prompt user for confirmation of selected commands to run If crt.Dialog.MessageBox("Following Commands will be executed " & _ vbCR & vbCR & crt.Clipboard.Text, "Command List:" , vbYesNo) <> vbYes Then _ Exit Sub |
#6
|
|||
|
|||
Hi kamal,
Thanks for the information. Another option came to mind. You could take the data from the clipboard, make a copy of it, and replace all CRLFs with a different separator. That would allow you to display all of the commands in a shorter space. So to recap, in addition to the option above, you could modify the example in the scripting manual to meet your needs or you could use multiple message boxes. |
#7
|
|||
|
|||
![]()
Hey Todd,
Thanks for your quick response. Solution to replace CrLF is good, but as I'm using this commands to fire on device later, it would not be a feasible option. While, I see html/IE object is the best solution as it would provide a window with scroll. But I don't know what to modify in example script to display my clipboard test over there, if you can help me with that portion of script, I would really appreciate ![]() |
#8
|
|||
|
|||
Hi kamal,
Quote:
Quote:
Here is something that might help you with your goal: Code:
' Get the commands in the clipboard. strCommands = crt.Clipboard.Text ' Create HTML to add commands to form. vCommands = Split(strCommands, vbcrlf) For Each strCommand in vCommands strHTMLBody = strHTMLBody & "<font color=blue>" & strCommand & "</font><BR>" Next ' Get a reference to IE's Application object Set g_objIE = CreateObject("InternetExplorer.Application") g_objIE.Offline = True g_objIE.navigate "about:blank" ' This loop is required to allow the IE object to finish loading... Do crt.Sleep 100 Loop While g_objIE.Busy g_objIE.Document.body.Style.FontFamily = "Sans-Serif" ' Inject the HTML code above into the IE object g_objIE.Document.Body.innerHTML = _ "<font color=black><b>Here are the commands that you copied:</b></font>" & _ "<hr>" & _ "<div style=""width:450px;height:150px;line-height:1em;overflow:scroll;padding:5px;"">" & _ "<font color=blue>" & strHTMLBody & "</font>" & _ "</div>" & _ "<hr>" & _ "<font color=red><b>Do you want to send the commands?</b></font>" & _ "<button name=OK AccessKey=O " & _ "Onclick=document.all(""ButtonHandler"").value=""OK"";" & _ "><u>O</u>K </button>" & _ " " & _ "<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 >" ' Prevent the MenuBar, StatusBar, AddressBar, and Toolbar from ' being displayed as part of the IE window g_objIE.MenuBar = False g_objIE.StatusBar = False g_objIE.AddressBar = False g_objIE.Toolbar = False ' Set the initial size of the IE window g_objIE.height = 300 g_objIE.width = 550 ' Set the title of the IE window g_objIE.document.Title = "Authentication Credentials Prompt" g_objIE.Visible = True ' This loop is required to allow the IE window to fully display ' before moving on Do crt.Sleep 100 Loop While g_objIE.Busy ' This code brings the IE window to the foreground (otherwise, the window ' would appear, but it would likely be behind the SecureCRT window, not ' easily visible to the user). 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... Do ' If the user closes the IE window by Alt+F4 or clicking on the 'X' ' button, we'll detect that here, and exit the script if necessary. 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, and address each one ' as it's clicked. Select Case g_objIE.Document.All("ButtonHandler").Value Case "Cancel" ' The user clicked Cancel. Exit the loop g_objIE.quit Exit Do Case "OK" ' The user clicked OK. Send the commands that were in the clipboard ' and then quit. ' Send commands... g_objIE.quit Exit Do End Select ' Wait for user interaction with the dialog... crt.Sleep 200 Loop |
#9
|
|||
|
|||
![]()
Thank you soo much Todd, Script worked as smooth as silk.
I truly appreciate your efforts for making my life easier. Thanks you sooo much. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|