How to wait for the Screen to catch up with my VBScript in SecureCRT?

995 views Asked by At

I'm trying to write a script for SecureCRT in VBScript that sends keystrokes to automate some of my more repetitive tasks for me. Normally, all I have to do is press a couple of keys, but I'm trying to have a script press them for me.

The issue is that no matter how long I set the screen to wait for using crt.Sleep, it seems to do just wait, then press all of the keys at light speed.

In essence, my code looks like this:

crt.Screen.SendKeys "{TAB}"
crt.Sleep 10
crt.Screen.SendKeys "{TAB}"
crt.Sleep 10
crt.Screen.SendKeys "f"
crt.Sleep 10
crt.Screen.SendKeys "p"
crt.Sleep 10
crt.Screen.SendKeys "p"
crt.Sleep 10
crt.Screen.SendKeys "r"
crt.Sleep 10
crt.Screen.SendKeys "{F10}"
crt.Sleep 10
crt.Screen.SendKeys "{ENTER}"
crt.Sleep 250
crt.Screen.SendKeys "v"
crt.Sleep 10
crt.Screen.SendKeys "{F10}"
crt.Sleep 10
crt.Screen.SendKeys "{ENTER}"
crt.Sleep 250

(It's gross, I know—I originally had a function written to get rid of all the repetition, but I lost some of my progress)

1

There are 1 answers

1
Moir On

I often use the following function to add pause time. I am not sure how "crt.Sleep 10" works but this may work better for you.

Function Pause(PauseTime)       
Dim Start = Timer
    Do While Timer < Start + PauseTime
        'Pause
    Loop
End Function