why i can't click the exists button?

Asked by lake

if exists( exist-img):
        print 'ok'
 click( exist-img)

after run ,will jump to control and show error:

ok
[info] click on (85,728), MOD: 0
[debug] close all ScreenHighlighter
[debug] close all ScreenHighlighter
[info] Exited with code 0

the test env:
1.linux system,debian
2.sikuli-X-1.0rc1 and sikuli-1.0 ,all exist this issue

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
lake
Solved:
Last query:
Last reply:
Revision history for this message
lake (firmlyjin) said :
#1

anybody can help me?

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

these are normal messages:

ok --- from your print
[info] click on (85,728), MOD: 0 --- from your click

if this is all your script, it terminates after the click (nothing more to do) and shows these messages
[debug] close all ScreenHighlighter
[debug] close all ScreenHighlighter
[info] Exited with code 0

--- a tip:
when using exists() to check the existence of a visual object, that you want to click if it is there, you can save the second search:
if exists( exist-img):
    print 'ok'
    click(getLastMatch())

since the exists() saves the match you can use getLastMatch() to get the click position.

--- one more thing:
since here in the messages it is not always obvious wether the de/indentation is correct after if, else, for, while and def:
Are you aware, that you are scripting in Python language, where grouping of statements is signaled by indentation/dedentation? In the IDE, use Tab and Shift-Tab for one level.

Revision history for this message
lake (firmlyjin) said :
#3

thank you,raiman.
but after change the srcipt :
if exists(exist-img ):
 print 'ok'
 click(getLastMatch)

still get error:
ok
[debug] close all ScreenHighlighter
[debug] close all ScreenHighlighter
[info] Exited with code 0

the script on windows is ok, why under linux ,gerate the issue?

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

you missed the () function call brackets with getLastMatch() - it is a getter method with no parameters.

have fun with Sikuli X ;-)

Revision history for this message
lake (firmlyjin) said :
#5

o,sorry.raiman, it's my misspelings,:)

if exists(exist-img ):
 print 'ok'
 click(getLastMatch())

still get error:
ok
[debug] close all ScreenHighlighter
[debug] close all ScreenHighlighter
[info] Exited with code 0

under windows,it's ok.but linux fail?
my test env issue?

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

sorry, but you do not "get an error", it is only, that not might happen, what you expect ;-)

In this case, the click is not reported after the ok is printed - and this is abnormal.

In my personal launchpad page https://launchpad.net/~raimund-hocke you can find my mail address. Just send me the .py file as a mail attachment that is contained in the .sikuli folder of your script. So I can have closer look at it.

Revision history for this message
lake (firmlyjin) said :
#7

hi rainman:)

thank you and your kindness

this morning ,i found maybe the problem accuse by i use left-mouse.

so i test two way:
1.after i change 'right-click',it's ok.
2.on linux system, change right-mouse from left-mouse, no the issue

but,in windows, i also use left-mouse,but no this issue.it's why?

now i can work,thank you,thank every sikuli's man,thank MIT!