The script does not work

Asked by Paul Weber on 2019-10-24

Hello colleagues!
Sorry for such an elementary question.
I don’t understand what am I doing wrong? Tell me how to cope with the following task:
I installed “Sikuli 2.0.0” on Windows10 and try to run a small script in the Sikuli IDE:

from sikuli import *
openApp ("C: \\ Users \\ User \\ CALK \\ calk-pro_x64.exe")
sleep (1)
click ("btn1.png")
sleep (1)
hover ("ktrbtnyes.jpg")
sleep (1)
click ("ktrbtnyes.jpg")

And instead of the expected result, I get a message:

[log] CLICK on L [126,850] @S (0) (538 msec)
[error] script [CAL] stopped with error in line 7
[error] FindFailed (ktrbtnyes.jpg: (1213x206) in R [0,0 1920x1080] @S (0))
[error] --- Traceback --- error source first
line: module (function) statement
7: main (<module>) hover ("ktrbtnyes.jpg")
[error] --- Traceback --- end --------------

I have java -version installed:
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3 + 7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3 + 7, mixed mode)

I took screenshots of the buttons myself, and not through the “Screenshot” in the Sikuli IDE. However, I inserted the button names into the script through the "Insert Image" in the Sikuli IDE.
What am I doing wrong?
Where should I place the folder with my project "CAL"?
What modules still need to be connected and how?
And what does the string "7: main (<module>) hover (" ktrbtnyes.jpg ") mean?

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-10-25
Last reply:
2019-10-25
RaiMan (raimund-hocke) said : #1

#from sikuli import * # not needed in IDE main scripts#

#openApp ("C: \\ Users \\ User \\ CALK \\ calk-pro_x64.exe")
# no intermediate spaces
# see docs for class App
calc = App("C:\\Users\\User\\CALK\\calk-pro_x64.exe")
calc.open()
if not calc.isRunning(10): # wait max 10 seconds
    exit(1)

# no sleeps needed, since search waits 3 seconds max for image
click ("btn1.png")
#hover ("ktrbtnyes.jpg") #does not make sense (click follows)
click ("ktrbtnyes.jpg")

Not sure, wether you have looked through the docs already:
https://sikulix-2014.readthedocs.io/en/latest/index.html

Depending on your monitor situation (HiDPI ?, scaling>100%?, ...) you might have problems with external snapshots
see: https://bugs.launchpad.net/sikuli/+bug/1730645
It is highly recommended to take the images with the IDE.

Paul Weber (weber19) said : #2

RaiMan, thanks for the advice! I tried to do as you wrote. Error messages have disappeared. However, in line
calc = App ("C: \\ Users \\ User \\ CALK \\ calk-pro_x64.exe") the name "App" is highlighted in red. I guess I forgot to connect the modules somewhere? What kind?
And yet, the program starts, but until a certain point. When I run the executable file, UAC (User Account Control) starts. A UAC window opens with the question “Do you want to allow this application to make changes to your computer?” And two buttons appear: “Yes” and “No”. I need to click the "Yes" button. How to do this, but in order not to disable UAC and click on the “Yes” button? How this issue is resolved using SikuliX. I tried to achieve this result with the command:
type (Key.TAB + Key.TAB + Key.ENTER), but I didn’t succeed ... Thanks in advance!

RaiMan (raimund-hocke) said : #3

--- the name "App" is highlighted in red
normal IDE syntax highlighting (red = SikuliX class)

--- When I run the executable file, UAC (User Account Control) starts.
Which executable are you talking about?
calk-pro_x64.exe???

if yes: why is it asking such things? has nothing to do with SikuliX.

--- type (Key.TAB + Key.TAB + Key.ENTER)
type (Key.TAB)
type (Key.TAB)
type (Key.ENTER)

is better, since you are now able to add short waits after each type to give time to the GUI (e.g. wait(0.3))

RaiMan (raimund-hocke) said : #4

... and again
calc = App ("C: \\ Users \\ User \\ CALK \\ calk-pro_x64.exe")

as already mentioned all those interleaving spaces are neither helpful nor according to the script language rules.
Spaces tend to make more problems then being helpful.

calc = App("C:\\Users\\User\\CALK\\calk-pro_x64.exe") # this way

Can you help with this problem?

Provide an answer of your own, or ask Paul Weber for more information if necessary.

To post a message you must log in.