Search code examples
user-interfacevbscriptscriptingeditsap-gui

SAP GUI Script: Set focus on Input Field in order to SendKeys


In my SAP GUI VBS Script, I want to paste the Clipboard to an Input Field. I use WshShell.SendKeys "^V", but it does not do anything and I suspect this because the Input Field has no focus.

So far my best guess was to "write" empty text into the field and then set the caret position to 0 and hope that this shifts focus to the field, but it does not help:

session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = ""
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 0

I have not found any methods for the session object, I hoped to find anything like session.setFocus or similar.

Is there a way to set focus on an Input Field?

Thanks


Solution

  • How about, for example, with

    session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").setfocus
    

    Regards, ScriptMan