How to use exact()?

Asked by DanielF

I'm trying to automate the running of SurCodeDTS from a batch file (it has no command-line interface, not even keyboard shortcuts!). After starting SurCodeDTS from the batch file, I can get Sikuli to click the 'Encode' button to start encoding, but I need to know when SurCodeDTS has finished encoding so I can close it (with Sikuli) and continue my batch file.

Once SurCodeDTS starts encoding, the 'Encode' button becomes greyed-out. So I tried this Sikuli instruction:
wait({screen-grab of Encode button}, 300)
but Sikuli ended before SurCodeDTS had finished encoding. I suspect Sikuli was finding a match with the greyed-out Encode button. So my next attempt was to use the exact() function, like so:
wait(exact({screen-grab of Encode button}), 300)
but then Sikuli generated an error box saying "... NameError: name 'exact' is not defined"

I can program assembler and C, but have no experience with Python/Jython. The Sikuli documentation seems to assume the user will be a Python programmer, so I'm lost.

Please explain how to use the exact() function to ensure Sikuli only terminates the wait() when an exact match is found (not the greyed-out button).

Thanks, Daniel

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
Best RaiMan (raimund-hocke) said :
#1

exact() is a convenience method of a Pattern object to set the expected similarity to 1 (exact match pixel by pixel).

usage:
wait(Pattern({screen-grab of Encode button}, 300).exact()

May be, that you have problems using exact(): I remember, that some people reported odd behaviors, when setting the expected similarity to 1 (despite the fact, that the match reported a similarity of 1.00).

so use
wait(Pattern({screen-grab of Encode button}), 300).similar(0.99)

Tip: A Pattern can be created from a captured image using the preview pane (click on the image thumbnail), by just moving the similarity slider away from 0,7, even if the image is not visible on the screen.

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

sorry correction:

usage:
wait(Pattern({screen-grab of Encode button}).exact(), 300)

and

so use
wait(Pattern({screen-grab of Encode button}).similar(0.99), 300)

Revision history for this message
DanielF (dfnojunk) said :
#3

RaiMan,

Many thanks for this (and your subsequent correction). It has solved my problem!

Out of interest, I found that 0.99 was too similar to work. After doing a binary trial-and-error search to find the similarity limits, I determined that 0.87 was the lower limit (no false find) and 0.95 was the upper limit (found the button), so I set the similarity value to 0.91.

I should also mention that the magazine that alerted me to the existence of Sikuli (PC Authority, Australia) said that it was compatible with WinXP upwards. I'm using it on Win2k Pro SP4. Admittedly a few things don't work [openApp(), closeApp() and switchApp() for starters], but I can work around those omissions.

Thanks (to you and the team) for an amazing application! It will now allow me to *completely* automate a tedious process of editing (volume scaling) and re-encoding hundreds of DTS surround audio tracks on my music server, even though Minnetonka Audio Software Inc don't have a command-line version of their DTS encoder.

Regards,
Daniel

Revision history for this message
DanielF (dfnojunk) said :
#4

Thanks RaiMan.

The
wait(Pattern({screen-grab of Encode button}).similar(0.99), 300)
solution with some tweaking of the similar value (to 0.91) worked beautifully.

A very clever and really useful project (even if slow and poorly documented :-)

Rgds, Daniel

Revision history for this message
DanielF (dfnojunk) said :
#5

I include phone numbers in my standard e-mail 'signature' as a courtesy to the receiver, but did not intend that they be published to the world!

I can't find a link to an administrator or moderator, so can someone please tell me how to get that part of this post removed?

Rgds,
Daniel
(Gerroa, Australia)

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

I guess you have to address the launchpad team at launchpad.net.