Sikuli Can't Click Image and Ask to Run the SikuliX Stuff as Admin

Asked by Nael Abd Aljawad

I'm trying to click on image using java, but no success.

Error :

[log] App.focus: [8364:BIStudio.exe] [log] CLICK on L(228,136)@S(0)[0,0 1920x1080] [error] RobotDesktop: checkMousePosition: should be L(228,136)@S(0)[0,0 1920x1080] but after move is L(-1099,728)@S(1)[-1366,306 1366x768] Possible cause in case you did not touch the mouse while script was running: Mouse actions are blocked generally or by the frontmost application. You might try to run the SikuliX stuff as admin.

What should i do here using java? I tried using the IDE and worked after running as Admin. Please help!

Thanks, Nael

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

looks like a multimonitor setup.

make sure, you are using the latest version of 1.1.1 in your java context.

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#2

I'm using 1.2.0 version .

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

You are using 2 different sikuli projects:
1. the one with the IDE is SikuliX (http://sikulix.com)
2. the 1.2.0 is this: https://code.google.com/archive/p/sikuli-api/

both are to some extent feature compatible, but have nothing to do with each other (except the developer is one of the original Sikuli developers)

Here you can only get help for 1.

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#4

Here is maven dependency i use:

               <dependency>
   <groupId>com.sikulix</groupId>
   <artifactId>sikulixapi</artifactId>
   <version>1.1.0</version>
  </dependency>

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#5

The java code:

import java.security.SecureRandom;

import org.sikuli.script.App;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;
import org.testng.Assert;
import org.testng.annotations.Test;

import base.ScreenShotsUtils;

public class PrismBIStudioTest extends BIStudioTest {

 private Screen screen = null;

 @Test
 public void biStudioTest() throws FindFailed, InterruptedException {
  App app = new App("BIStudio.exe");
  app.focus().makeAppEntry();
  screen = new Screen();
  // screen.click(ScreenShotsUtils.biStudioScreenshotsPath +
  // "WelcomeAutoTestCloseButton.PNG");
  Thread.sleep(5000);
  screen.wait(ScreenShotsUtils.biStudioScreenshotsPath + "SheetToolsButtons.PNG", 5);
  screen.click(ScreenShotsUtils.biStudioScreenshotsPath + "DataBrowser.PNG"); /////////////// fails here!

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

try with

    <dependency>
   <groupId>com.sikulix</groupId>
   <artifactId>sikulixapi</artifactId>
   <version>1.1.1-SNAPSHOT</version>
  </dependency>

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#7

Hi RaiMan,

This dependency is not working for me, it says "Missing artifact com.sikulix:sikulixapi:jar:1.1.1-SNAPSHOT".

Thanks,

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

ok, sorry.

you have to add the snapshot repo pointer:

<repositories>
  <repository>
    <id>sonatype-ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  </repository>
</repositories>

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#9

Sorry RaiMan, the same problem!

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

Can you please add as JVM parameter:

-Dsikuli.Debug=3

and send me the debug output to my mail:
sikulix--at--outlook--dot--com

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

You have at least 2 monitors attached.

Please describe the configuration.

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#12

Hi RaiMan,

I have sent Log Output to your email.

I tried with one monitor and two.

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

ok, got the log.

apparently the mouse cannot be moved anymore, after your app "BIStudio.exe" has been started:

--- before the app start:
[debug] Screen: initScreens: multi monitor mouse check
[debug] Screen: *** checking: S(0)[0,0 1920x1080] center: (960, 540) --- OK
[debug] Screen: *** checking: S(1)[-1366,306 1366x768] center: (-683, 690) --- OK

with this start up check, the mouse is moved (delay 0) to the center of each screen and the position is checked afterwards.
This apparently works.

--- after start of app:
should be L(228,136)@S(0)[0,0 1920x1080] but after move is L(867,482)@S(0)[0,0 1920x1080]
with the corresponding click: [debug] CLICK on L(228,136)@S(0)[0,0 1920x1080]

and with the next click:
should be L(50,354)@S(0)[0,0 1920x1080] but after move is L(867,482)@S(0)[0,0 1920x1080]
[debug] CLICK on L(50,354)@S(0)[0,0 1920x1080]

As you can see, the mouse position is still reported to be L(867,482)@S(0)[0,0 1920x1080], though the 2 requested clicks should have moved the mouse.

You should run a testcase, without starting your app: just a click on something visible on the screen.

I guess the last click would have revealed the next image, that gets a FindFailed finally.

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#14

I see that after app focus i get that error.
I tried to focus using ALT+TAB, Thread sleep then click on App.... no success and got the same message.
When i try without focusing the mouse reveal the button and move but click not doesn't work.

This is really strange.

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

If I understand right, then this simply means, that mouse animation using Java AWT Robot (used in SikuliX) is blocked, when your app is the frontmost.

I am sorry, but I do not have any idea besides the option, to start your workflow from an admin commandline (which in some cases helps)

Revision history for this message
Nael Abd Aljawad (nael-null) said :
#16

Yes right.
How to start my workflow from admin command-line while using Eclipse IDE for running?
Is SikuliX will be affected?

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

--- admin commandline
depending on the Windows you have: a right click on the entry/icon to open a command line should reveal a menu entry saying something like "... run as administrator ...". If successful, then the window title shows a different naming.

--- with Eclipse
you have to start Eclipse from such a commandline, to have a chance to run your workflow this way from within Eclipse (but might not work).

--- outside of Eclipse
export your project as a suitable jar and run that jar from that admin commandline using
java -jar <you-name-it>.jar

maybe this helps:
https://answers.launchpad.net/sikuli/+question/295298 comment #8

Can you help with this problem?

Provide an answer of your own, or ask Nael Abd Aljawad for more information if necessary.

To post a message you must log in.