Problem with App class in linux

Asked by Jose Miguel

Hello,

I've started a java project recently, which is sikuli-based. My environment is ARCH linux + eclipse + sikuli java API + KDE plasma.

Imagepath. Screen class, mouse.hover(), click() , etc. etc.... all of that works great. Pretty impressive stuff, I must say.

However, I've spent several hours in order to make the App class to work, but to no avail. I am a bit confused, since, according to the docs, its methods are pretty simple and self-explanatory.... and, well, Hell take me, but I've not been able to get such a simple piece of code to work:

---------
App browsy = new App("chromium");
  browsy.open();

  try
  {
   Thread.sleep(3000);
  }
  catch(InterruptedException ie)
  {}

  browsy.focus();
  browsy.close();
-------------

Chromium will open in a new window (lo and behold) , which is fine and ok. But after that, the window will not close. In fact, I cannot seem to be able to control the app object at all. I mean, for example:

- both isValid() and isRunning() will return false

- close() will do nothing, i.e., I can open a chromium window, but I cannot close it.

- if you purpousefully take the focus to another window (by simply clicking on it) , after the trhee seconds delay, browsy.focus() won't work either, i.e., the chromium window won't become the front-most window in the screen.

- getTitle() returns an empty string, getName() returns "chromium".

It seems like, I don't know, like if the app object, once I've called open() on it, wouldn't be able to "recognize" the chromium window anymore.

If you could shed some light on this one, I'd be very grateful !

thanks for your time,

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

Sorry for the inconvenience.

Currently and for the next few weeks I do not have an environment nor time (in the sense of priority) to evaluate Linux related problems.

Since you are using Java, you might look into the App/LinuxUtil classes for possible solutions.
See the related bug.

Internally xdotool and wmctrl are used to do the job.

Use for example Java's ProcessBuilder to issue your own commands to solve your problem.

Revision history for this message
Brent Villalobos (brentv) said :
#2

I know this is an old thread, but I ran into a similar problem on CentOS-7. The App class can launch the app, but after that it doesn't know how to query it:

>>> terminal = App("/bin/gnome-terminal")
>>> terminal.isRunning()
False
>>> terminal.open()
[error] openApp:
offset 0, count -1, length 64
False
>>> terminal.isRunning()
False
>>>

I know that SikuliX is using xdotool and wmctrl under the hood and I have both installed. I'll probably need to implement my own functionality for querying processes. I see that xdotool is used heavily in LinuxUtil.java (https://github.com/RaiMan/SikuliX1/blob/master/API/src/main/java/org/sikuli/natives/LinuxUtil.java). However, I don't see where wmctrl is used in the codebase. I searched for it in the github repository and there was no code hits.

Can you help with this problem?

Provide an answer of your own, or ask Jose Miguel for more information if necessary.

To post a message you must log in.