Is there a way to tell Sikuli to wait until clipboard context change?

Asked by eduardobedoya

I am using ABBYY Screenshot Reader to OCR capture some text in a flash website,
ABBYY automatically save the text in the clipboard, it take some time do that, sometimes is 3 secs, sometimes is 9 secs.
I need to repeat this task several times, is there a way to detect when it has finished to OCR Process and creates the new clipboard content?

May I need to create a Busy Loop?
something like...

BeforeABBYY = App.getClipboard();
AfterABBYY = App.getClipboard();

While 'BeforeABBYY' == 'AfterABBYY':
    AfterABBYY = App.getClipboard();

Im right? please tell me if there is any other way to achieve this,
sorry if it is python syntax, I just would like to know if there is not any other better way (avoiding Busy Loop) to do this using either Sikuli clipboard operators or JAVA script.

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:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

I would insert a wait, to not make the cpu too busy:

BeforeABBYY = App.getClipboard()

while BeforeABBYY == AfterABBYY:
    AfterABBYY = App.getClipboard()
    wait(1)

BTW: per convention variables in Python should start with a lowercase letter, names starting with uppercase should be reserved for lass names and constants (usually all uppercase)

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

correct:

BeforeABBYY = App.getClipboard()
AfterABBYY = App.getClipboard()

while BeforeABBYY == AfterABBYY:
    AfterABBYY = App.getClipboard()
    wait

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

Thanks Raiman
So there is not other way to do this right?
I thought I read something about JAVA script to get clipboard changes, that could be used in Sikuli
PD: yes RaiMan, Im having a pain finding logic names to variables
eg.
matches
allMatches
sortedAllMatches
etc
Thanks.

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

--- I read something about JAVA script to get clipboard changes,

not an option currently in Sikuli's clipboard implementation.

If you have knowledge in Java programming, then feel free, to add what you want to your Jython scripting.
In Jython scripts you have full access to any Java feature available on Java class path.

Observe changes on the clipboard is a good idea - I add it to the list for version 2.

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

Thanks RaiMan, that solved my question.