SUPPORT > SECURECRT > VBSCRIPT TO RESTORE HIDDEN WINDOW
Send us a question or comment

 

Send us your tip idea


Below is an example of a VBScript that can save you some time by automatically restoring a SecureCRT® or CRT™ session window as soon as output from a remote machine is detected. This tip initially appeared in our July 2003 newsletter.

VBScript to restore session window when remote output is detected

Ever needed to send a build of your latest work to a customer or your boss by the end of the business day and didn't do it? If you're like me, you log on using SecureCRT, start the build with a "make >& make.errs" and promptly minimize the SecureCRT window. Then, you're answering e-mail and phone calls. Sure enough, the end of the day comes and you remember that the build should be finished. When you restore the SecureCRT session and take a look at the make.errs file, you find:

*** Build failed ***

You forgot to check in a needed file. And your bus home arrives in ten minutes. Now you won't have time to do the build until tomorrow.

If the SecureCRT session window could have popped up as soon as the command finished, you could have easily checked in the missing file and restarted the build. Not only that, you could have sent your boss the build at 3:30 p.m. (when it might have done her some good) instead of 6:30 a.m. the next morning.

Here's how you can do just that. Below is an example of a simple VBScript that will restore a hidden or minimized SecureCRT or CRT window when output from a remote machine is detected.

Let's say you run the following command under UNIX to start the build:

   % make >& make.errs

Then, manually from the Script / Run menu, start the script below. When the build finishes, the cursor will move, the script will detect it, and the window will be restored.

 


#$language = "VBScript"
#$interface = "1.0"

' Note: Both SecureCRT and CRT use the "crt" application
' scripting object.

Sub Main
    Do
        ' Wait for the cursor to change position. This
        ' will indicate activity or output from the remote.
        crt.Screen.WaitForCursor

        ' Restore the CRT Window associated with the
        ' current session only if the window is currently
        ' hidden (to the Activator) or minimized
        If crt.Window.State = 0 Or crt.Window.State = 2 Then
            crt.Window.Show 1
        End If
    Loop
End Sub

Tell us what you think. Did you find this tip useful? Do you have a question you'd like us to answer? Send your comments and questions to VanDyke Software Support.