Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The text cannot be placed on the clipboard
#1
Sometimes it doesn't work, the text in the variable 'text' cannot be placed on the clipboard. Is there a more stable solution for the following code?

string text = "hello";
clipboard.text = text; e2.SendKeys("Ctrl+A", "Ctrl+V");

I often use the following method, which works,
but I don't know why the clipboard doesn't save the text on the first attempt.

string text = "hello";

__L:
clipboard.text = text; 

try
{
e.SendKeys("Ctrl+A", "Ctrl+V");
//....
}
catch (Exception er) { print.it(er); goto __L; }
#2
Your try/catch is OK.
#3
I don't understand why placing text on the clipboard fails the first time.  Huh

This situation occurs almost every time the script is executed.

As a workaround, can use the following 'retry' function for replacement(goto lable)?

https://www.libreautomate.com/forum/show...1#pid37691

If there could be a simple solution, that would be great. I don't want to use too many 'goto' labels.
This is currently the most challenging problem I've encountered. It's difficult to detect in several tests, only becoming apparent after extensive testing.

My suggestion is to have a global retry option (E.g: opt.retry=3). When enabled, all relevant commands would default to using the retry functionality.


Forum Jump:


Users browsing this thread: 1 Guest(s)