← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #185777]: copy and paste text from web page to variable or anything

 

Question #185777 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/185777

    Status: Open => Answered

RaiMan proposed the following answer:
The function you need is 
Env.getClipboard()

which returns the current text content of the clipboard.

doubleClick(Pattern("Projectspost-2.png").targetOffset(7,-1))
type("c", KEY_CTRL)
cb = Env.getClipboard()

now cb contains the text, that was copied from the selection produce by
the doubleClick using ctrl-c.

This was the good news.

Now the bad news:
Together with paste(), Env.getClipboard() only works correctly until after the first usage of paste(). Then it always returns the string that was last pasted with paste() and not what you expect to be on the clipboard (this is an open bug :-(

So if you need paste() (because the text cannot be used with type() (faq
933)) in your script, Env.getClipboard() will not work for you.

If you can use type() to get something written on the screen, you can
use Env.getClipboard().

If you are familiar with Java, you might implement your own clipboard
feature together with your own paste() function.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.