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:

CODE:

doubleClick(<img>)
type("a", KEY_CMD)
size = type("c", KEY_CMD)
switchApp("Firefox.app")
click(<img>)
type(size)

ERROR:

[sikuli] [Error] source lineNo: 6
[sikuli] [Error] Traceback (innermost last):
  File "/var/folders/OI/OIujfWUTG3CWtdB94mnpjk+++TM/-Tmp-/sikuli-tmp4930914769136365198.py", line 6, in ?
  File "/Users/XXXXXX/Desktop/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar/Lib/python/edu/mit/csail/uid/Sikuli.py", line 514, in type
TypeError: type(): 2nd arg can't be coerced to String

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2010-02-03
Last reply:
2010-02-03
Andy.G (agibel07) said : #1

http://sikuli.org/documentation.shtml#doc/pythondoc-python.edu.mit.csail.uid.Sikuli.html

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.