Env.getClipboard does not return anything

Asked by Sam

Here is my code:

click("1499974350527.png")

type("a", KeyModifier.CTRL)
wait(1)
type("c", KeyModifier.CTRL)
wait(1)
Text = Env.getClipboard()
print Text

This function copies the text properly (I can paste it afterwards), but does not assign anything to Text and print Text returns nothing.

Any insight is appreciated. Thanks

Question information

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

What versions of SikuliX, system and Java?

Revision history for this message
Sam (staffo08) said :
#2

SikuliX: 1.1.1

System: Windows 7

Java:

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) Client VM (build 25.101-b13, mixed mode)

Thank you!

Revision history for this message
RaiMan (raimund-hocke) said :
#3

looks like 32-Bit?

try with the nightly build 1.1.2

Revision history for this message
Sam (staffo08) said :
#4

Yes, it is 32 bit (despite having a 64 bit computer), but it has worked in the past with 32 bit java.

I wish I could get 64 bit java, but unfortunately that isn't an option right now at work. Perhaps I'll try the nightly build if I can get that installed.

Thanks again.

Revision history for this message
Sam (staffo08) said :
#5

Hmmm, perhaps it is working :

click("1499974350527.png")

type("a", KeyModifier.CTRL)
wait(1)
type("c", KeyModifier.CTRL)
wait(1)
#Text = Env.getClipboard()
print Text
click("1499974394454.png")
paste(Env.getClipboard())
print "butt"
print len(Text)

When I print the length of the text it calculates it length. It will print "butt" in the message area and the length of what is in the clipboard. It just won't print the contents of the clipboard.

Any way, it seems like it is grabbing the text, but for whatever reason when I try to print it, it doesn't show up in the message area of the IDE

Revision history for this message
RaiMan (raimund-hocke) said :
#6

because of this
#Text = Env.getClipboard()

Text is not given a value, so it is something else.

Try this:
click("1499974350527.png")

type("a", KeyModifier.CTRL)
wait(1)
type("c", KeyModifier.CTRL)
wait(1)
myText = Env.getClipboard()
print myText

as a convention: variable names should start with a lowercase letter

Revision history for this message
Sam (staffo08) said :
#7

It's showing up in the message area now... Not sure why, but it's working! Thanks again

Revision history for this message
Sam (staffo08) said :
#8

Wow, I didn't realize I sent that with the Text = Env.getClipboard() line commented out... Sorry for the stupid question. Should have picked up on that myself.

It's working now on my main code so it's all good either way.

Sikuli really is awesome! It saves so much time at work. Thanks again!

Revision history for this message
RaiMan (raimund-hocke) said :
#9

user said so