on 2024 Jun 19 11:44 PM
Hello,
I am trying to select the text on a SAP GUI control and copy it to the clipboard.
I have been able to navigate through the tabs and menus but cannot understand how the text can be selected (can be small or longer texts) and the button can be pressed to achieve this.
Image for reference attached.
We have been blocked for using the scripts recording and if it wasn't for Stefan Schnell tracker it would be even worse. We can still run scripts to the moment and it is a very useful tool.
Can anyone help?
Thank you.
Hello @ptuga,
try this to copy the text of a TextEdit control to the clipboard. This C# example selects the first 1024 characters of TextEdit control, gets the selected text and copies it to the clipboard.
ID = InvokeMethod(session, "findById", new object[1]{"wnd[0]/usr/shell"});
InvokeMethod(ID, "SetSelectionIndexes", new object[2]{0, 1024});
string selectedText = GetProperty(ID, "SelectedText", new object[0]);
System.Windows.Forms.Clipboard.SetText(selectedText);
Important hint: To use the clipboard SetText method from System.Windows.Forms it is necessary to set the ApartmentStateAttribute of the main function to single-threaded apartment (STA) [STAThread].
Best regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan-Schnell: Thank you for the hint on how to select the text on such object. If we don't know how many chars we have, is 1024 the max?
I have also used the GetProperty(editBoxID, "text") to get the contents without having to have any text selected.
I have tried both solutions and both work.
User | Count |
---|---|
71 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.