View Single Post
  #12  
Old 11-05-2019, 04:07 AM
bodozs bodozs is offline
Registered User
 
Join Date: Oct 2019
Posts: 2
Hi Michel,

I've added an input box to the script. It will as how many seconds shall the script spend on each connected tab. If no meaningful input is provided (or Cancel was selected) then 2 secs will be used as default.

I also changed the status bar message using your idea. Now it contains the current tab number and the number of connected/total tabs as well.

regards,
Zsolt

Code:
# $language = "VBScript"
# $interface = "1.0"
' Set the default wait time in seconds. Each connected tab will be displayed for this amount of time.
nWaitTime=2

' The default time can be overwritten by using this input box
sWaitTimeInput = InputBox ("Specify how long each tab should be displayed (in seconds)","Display time", nWaitTime)

' We change the default value if a meaningful number was specified
If IsNumeric (sWaitTimeInput) and not IsEmpty(sWaitTimeInput) Then
	nWaitTime = Abs (Int (sWaitTimeInput))
End If

' Start with the tab in which the script is launched.
nCurTab = crt.GetScriptTab().Index

Do
' First, prepare the "x/y Connected" report for the status bar...
    ' ###############################################################
    nTotalTabs = crt.GetTabCount
    nConnected = 0
' Iterate through all of the tabs, finding out how many are connected:
    For nIndex = 1 To nTotalTabs
        Set objCurTab = crt.GetTab(nIndex)
        If objCurTab.Session.Connected Then
            nConnected = nConnected + 1
        End If
    Next

' Compose a report of the number of connected/total tabs:
    strTabReport = "Current tab: " & nCurTab & "       Connected/Total tabs: " & nConnected & "/" & nTotalTabs
    ' ###############################################################
' Now, activate the current tab and display the report:
    ' Activate the current tab.
    Set objCurTab = crt.GetTab(nCurTab)

' Switch to the tab only if it is connected
	If objCurTab.Session.Connected Then 
        objCurTab.Activate
    ' Display the data to SecureCRT's active tab
        objCurTab.Session.SetStatusText strTabReport
    ' Now, wait a couple of seconds for any keystroke to occur
        If objCurTab.Screen.WaitForKey(nWaitTime) Then
            ' Let the user know we've bailed on the script.
            objCurTab.Session.SetStatusText "Bailed due to keystroke."
            Exit Do
        Else
            ' Clear the status text on the current tab before we move
            ' on to the next tab -- this way, there isn't stale data
            ' in the status bar on tabs after this script exits/bails.
            objCurTab.Session.SetStatusText ""
        End If
    End If
' Otherwise, move on to the next tab.
    nCurTab = nCurTab + 1
    ' If we've gone beyond the last tab, cycle through to tab #1:
    If nCurTab > nTotalTabs Then nCurTab = 1
Loop
Reply With Quote