How could I place a string, the found image count, and their XY coordinates into the clipboard with Sikuli?

Asked by eduardobedoya

Is it possible to place a string (defined text), and the found image count and XY coordinates into the clipboard content with Sikuli?
I would like to place this text "job ended" inside clipboard content just before a script ends.
I think changing clipboard is faster than displaying a message when job is ended, cuz the former doesn't cover the screen, which is usefull since there are other sikuli jobs that run after the firstone ends.
Is it possible? Any workaround?
Thanks Advanced

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
eduardobedoya (gonnabdh) said :
#2

For example, I have a script that count the number of images found in the screen, I would like to store the result (found: 18) into the clipboard, just before end the script. Is it possible with sikuli?? thanks Advanced.

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

for version 1.1.0+

App.setClipboard("some text")

Revision history for this message
eduardobedoya (gonnabdh) said :
#6

THanks Raiman,
This is my script

count = 0
try:
    matches = list(findAll("1428702277851.png"))
    count = len(matches)
except FindFailed:
    pass #nothing to do
print "found:", count

I would like to put "count" (the variable number) into clipboard, is this possible???? I've tried:

App.setClipboard("count") it shows literally count as text
App.setClipboard(count) it shows [error] TypeError ( setClipboard(): 1st arg can't be coerced to String )
App.setClipboard("$count$") also literally
App.setClipboard(", count") also literally
App.setClipboard(, count) it shows [error] SyntaxError ( "no viable alternative at input ','", )

How can I do this, which part of sikuli 1.1 talks about this? is this possible??
Thanks Advanced

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

instead of hacking around, you should have tried to ask the right question:
since App.setClipboard() expects some text (string) as parameter:
How can a number converted to a text string?

the answer, which is simply Python specific again:
countAsText = str(count)

or even
"%d" % (count)

the second version is handy for situations, where you want to put more than one variable into the text and enhancing it with some words.

Both can be found in the Python docs and very early in any Python tutorial.

Revision history for this message
eduardobedoya (gonnabdh) said :
#14

Thanks RaiMan, that solved my question.