0

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

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
A BC
  • 3
  • 2
  • 5

1 Answers1

0

How about, for example, with

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

Regards, ScriptMan

  • Seems to work, now I have to find out why my `WshShell.SendKeys "^V"` does not paste. – A BC Mar 10 '15 at 10:16
  • `^V` (`CTRL + V` shortcut) is equivalent to `V78` virtual key. See more about virtual keys at [this](https://experience.sap.com/files/guidelines/References/nv_fkeys_ref2_e.htm) link. – Diogo Feb 25 '16 at 17:43