Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
little script to change \ to /
#1
I'm trying to write a small script which change any backslashes found in the text in the clipboard to / and then paste the resulting text into the current app.
My script is:
Code:
Copy      Help
            string s = clipboard.copy();
            s = s.Replace(@"\","/");
            print.it(s);
            clipboard.paste(s);

Two problems:
  1. often times I'm getting an error in LA:
    Warning: Au.Types.AuException: Failed to copy.
       at line 83 in Hotkey triggers.cs, Program.<>c.<TextTools>b__11_5(PMItem o)

    (line 83 is the first line shown above)
  2.  the print command in the 3d line shows the original text, so it seems my line 2 doesn't do what it should - but I don't see any fault there!?
#2
Quote:found in the text in the clipboard

Then replace the first line with
 
Code:
Copy      Help
string s = clipboard.text;

clipboard.text just gets text from the clipboard.

clipboard.copy sends keys Ctrl+C, waits and gets text from the clipboard. Trows exception if nothing responds to Ctrl+C or if fails for some other reason eg a bad clipboard manager app.

2. Impossible. That printed text came from elsewhere.
#3
Very nice, thanks!   Using clipboard.text fixed it all  Smile


Forum Jump:


Users browsing this thread: 2 Guest(s)