Copy text to become a Variable

Asked by LP81 on 2010-02-03

I am able to copy a chuck of text consistently, however I want to take the result from the copy and make it a variable to call up later (just in case I have multiple copy commands in 1 script)

When I try to do this, Siklui pops back an error:


type("a", KEY_CMD)
size = type("c", KEY_CMD)


[sikuli] [Error] source lineNo: 6
[sikuli] [Error] Traceback (innermost last):
  File "/var/folders/OI/OIujfWUTG3CWtdB94mnpjk+++TM/-Tmp-/", line 6, in ?
  File "/Users/XXXXXX/Desktop/", line 514, in type
TypeError: type(): 2nd arg can't be coerced to String

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
Andy.G (agibel07) said : #1

type returns a 0 or 1 which corresponds to whether or not it typed anything. type(size) crashes because type expects a string.

LP81 (pjbreen) said : #2

I understand why it breaks it, I would like to know how make it work...

RaiMan (raimund-hocke) said : #3

After you typed CMD-C, your whatever is selected remains in the clipboard until it's overwritten by another CMD-C.

So it's just fine to type("v", KEY_CMD) and paste the clipboard when you have your targetfield in focus (what should be the case after your last click()

LP81 (pjbreen) said : #4

I plan to use multiple copy/paste instances thruout my process, which is why i wanted to make it a variable so I can copy everything up front, set it to variable and then recall them all later... rather than copy here change window, pase, go back, copy, switch paste etc...

Sergey Darovskih (darovskih) said : #5

You can't do this at the moment. If I were you, I'd use Excel sheet for temporary strings.

Can you help with this problem?

Provide an answer of your own, or ask LP81 for more information if necessary.

To post a message you must log in.