cancel
Showing results for 
Search instead for 
Did you mean: 

ctx.clipboard.set malfunction and change the newline character

ZhangMingquan
Advisor
Advisor
0 Kudos

Hello RPA mates,

When I copy the following multi lines of numbers from notepad, and paste them to SAP GUI Multiple Selection, it works.

1910

2210

But in the following code, I tried to set the clipboard with defined text, then manually paste them to SAP GUI after each set method, SAP GUI always gave an error, complaining the content are not numbers.

After comparing the content, clipboard.set method changed \r\n line separator to \n automatically, anyone know how to prevent this or how to solve this?

Best Regards,

Mike

	var mytext = '1910\r\n2210';
	var copied = ctx.clipboard.get(); //copy the above numbers first then get them
	var eq = copied === mytext;  //true
	ctx.clipboard.set(mytext);
	ctx.clipboard.set(copied);
	var copied2 = ctx.clipboard.get();
	var eq2 = copied2 === mytext;  //false
	var mytext2 = '1910\n2210';
	var eq3 = copied2 === mytext2; //true

Accepted Solutions (1)

Accepted Solutions (1)

Jerome
Advisor
Advisor

Hi,

I don't know how to prevent it but you might be able to solve this using the following piece of code :

mytext2 = mytext2.replace(/\n/g, '\r\n');

Regards,

J.

Answers (0)