Need to find a way for sikuli to know if its running its scripts in google chrome via windows or mac

Asked by Iole

Hi,

Im new in sikuli and would like to ask for your help in how to determine that my script is running in google chrome for win or in mac

This is my code

if(App("Google Chrome").window()):
  print "Opened"
else:
 print "Not opened"

That script works fine in mac, sikuli knows when google chrome is opened however in windows. it always print "Opened" even if google chrome is not opened.

Thanks,

Question information

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

what version of SikuliX?

Revision history for this message
Iole (markiole-saberon) said :
#2

the newest version of sikulix 1.1.0 nightly build 2015-6-10_01:00

Revision history for this message
Iole (markiole-saberon) said :
#3

try to download the newest sikuli nightly build now, will let you know

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

with the latest 1.1.0 you can try this:

if Settings.isMac():
    chrome = App("Google Chrome")
else:
    chrome = App("chrome")

if not chrome.isRunning():
    print "Chrome not running"
    exit()

Revision history for this message
Iole (markiole-saberon) said :
#5

Thank you for the prompt response however when running, if chrome is open: it runs but if the chrome is not open there is an error [error] script [ Swipe1 ] stopped with error in line 6
[error] java.lang.NullPointerException ( java.lang.NullPointerException )

Tried to re-dl the sikuli and this code works(strange...)

if(App("Google Chrome").window()):
  print "Opened"
else:
 print "Not opened"

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

2fast4me ;-)

Sorry for misleading: I just realized, that the isRunning() feature is not available yet on Mac.
So you have to stay with your solution for now.

… and I think it should be possible to setup an App object, that automatically uses the right app-name-string on the system it is running on. I will implement this.

On Windows App("chrome").isRunning() should work.

--- and this code works(strange…)
not strange at all for the developer (that's me ;-), because the feature you use now, is not affected by the bug.

Revision history for this message
Iole (markiole-saberon) said :
#7

Thanks again Raiman!