Copy empty field, Env.getClipboard() not returning correctly

Asked by Chan Kok Lum

Hi guys,

I have a question regarding clipboard. I have been trying to avoid using paste() with Env.getClipboard(), still it doesn't work as i expected.

I have 3 textboxes. I need to start from top (textbox 1, read and replace the value, then move to textbox2 and so forth). It works fine in most conditions except when i hit textbox is empty.

Code :
type("a",KeyModifier.CTRL)
type("c",KeyModifier.CTRL)
print len(Env.getClipboard())
type(Key.DOWN)
type("a",KeyModifier.CTRL)
type("c",KeyModifier.CTRL)
print len(Env.getClipboard())

Example 1:

Textbox1: Test
Textbox2: <blank>

Both returning me 5 and 5. I expect the result be 5 and 0.

Example 2:

Textbox1: Test
Textbox2: Hello

The results here return as expected, 4 and 5.

Any advise ?

Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

It seems, that the normal GUI behavior with ctrl-c is, that an empty selection does not change the clipboard content, so it still contains the last content.

This is reflected by Env.getClipboard(): it returns the last content, if the clipboard content was not changed after copying an empty selection.

Since Sikuli currently has no feature to set/reset the clipboard to a defined content, you might find out, that an entry field still contains the last content (if this is logically possible with your app), by comparing current and last content.

If this is critical for you, you might implement your own clipboard handling using the respective Java classes in your Sikuli script.

Feel free, to post a request bug.

Can you help with this problem?

Provide an answer of your own, or ask Chan Kok Lum for more information if necessary.

To post a message you must log in.