type("v",KEY_CTRL) does not return clipboard content - use Env.getClipboard()

Asked by Raphael Silva

How do for association a variable (type("v",KEY_CTRL)) e save in file?

try:
    dragDrop("Pd-1.png", "al-1.png")
except:
    dragDrop("1365085975403.png","line.png")
type("c",KEY_CTRL)
f = open('msn.txt' ,'r+')
a =(type("v",KEY_CTRL))
print a
f.write(a)
ler = f.read()
f.close()

print ler

Question information

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

you seem to expect, that

a =(type("v",KEY_CTRL))

returns the content of the clipboard.

But that is not the case: type() simply simulates key presses and returns 0 or 1 (print a should have told you), which in turn leads to the error at
f.write(a)

which needs a string value (no auto-conversion like with print)

If I guessed your intention right:

try:
    dragDrop("Pd-1.png", "al-1.png")
except:
    dragDrop("1365085975403.png","line.png")
type("c",KEY_CTRL)
f = open('msn.txt' ,'r+')
a =Env.getClipboard()
print a
f.write(a)
ler = f.read()
f.close()

print ler

Revision history for this message
Raphael Silva (raphaelcoel) said :
#2

Thank you RaiMan. My problem was solved. I'm sorry, I'm begin in sikuli.