arraysstringvbscriptuft14

How to type full string without stopping in the middle?


I'm trying to type a full string in some field but the type function doesn't write all of the text.

I got an object of a text field and I'm trying to fill it with type function. For some reason, the type function writes only part of the text. First of all, I remove all the text that used to be and then type the new text with type function.

InputAreaObj.Type micCtrlDwn + "a" + micCtrlUp 'select the text
InputAreaObj.Type  micDel   'remove it
InputAreaObj.Click 0,0          'click on the object
InputAreaObj.type CodeToExecute  'type the string

I just want the text to show up, full of it and not part of it. I tried to use split to separate the string to array and it doesn't work. thanks!


Solution

  • The Type() method might be limited by keyboard buffer, repeat rate, and/or simple char-code sequences -- similar to the WScript.Shell object's SendKeys() method. That said, you may need to wait (Sleep) between sending each character using the Type() method.

    For example, try replacing your last line above with something like this:

    For i = 1 To Len(CodeToExecute)
        InputAreaObj.Type Mid(CodeToExecute, i, 1)
        WScript.Sleep 500
    Next
    

    This example sends one character at a time to your InputAreaObj, while giving it sufficient wait time to process and render each character as it receives them.

    Keep in mind that if your InputAreaObj renders markup like HTML, then there's a chance the characters contained within CodeToExecute might 'hide' a portion of the text (depending upon the markup provided), giving it the illusion that InputAreaObj didn't actually receive all the characters, when in fact it did.

    Hope this helps.