[1.1.0] OSX 10.7: Can't use App.open, openApp, App.focus running script from IDE started as app --- workaround: run script from Terminal

Asked by Linda

Updated to latest build of 1.1 today, and my scripts that previously worked fine on 1.0 have now stopped working..

Env:
Mac 10.7
Sikuli IDE 1.1 2015-06-04

I can't open any app with Sikuli, I have tried the following:
# Open the app if its not already open
openApp("Safari.app")
wait(2)
App.open("Safari.app")
wait(2)
App.focus("Safari.app")

It just blinks in the Dock, and then nothing happens (app not docked)

output:
[log] App.open [-1:Safari]
[log] App.open [-1:Safari]
[log] App.focus: [-1:Safari]

Question information

Revision history for this message
Linda (linda-nordstrom) said :
#1

Anyone else seeing this or is it just on my machine?

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

I have revised the App class, to be more functional on Windows.
This seems to have some drawbacks on Mac (under investigation).

This works (tested on OSX 10.7):

bs = App("Safari")

bs.open() # open and focus
bs.focus() # has the same effects as open() on Mac currently

bs.close() # close the app

Revision history for this message
Linda (linda-nordstrom) said :
#3

if I run it like that I'm getting the following error:
(maybe I should take a newer build of Sikuli 1.1? mine is from June 10th)

----------------------------------------------------------------------------

[error] Runner: AppleScript:
tell application "System Events"
set found to "NotFound"
try
set found to first item of (processes whose unix id is equal to 0)
end try
end tell
if not found is equal to "NotFound" then
set windowName to ""
try
set windowName to name of first window of application (name of found)
end try
set found to {name of found, «class idux» of found, windowName}
end if
found

returned:
*****error*****
/var/folders/xb/n4mh65r97xx60spypnnys5pc0000gn/T/Sikulix_517854424/sikuli-2507365976302644706.script:110:112: script error: Expected “,” but found property. (-2741)

[error] script [ test ] stopped with error in line 3
[error] java.lang.ArrayIndexOutOfBoundsException ( java.lang.ArrayIndexOutOfBoundsException: 2 )

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

yes, use latest build (sorry, for not mentioning it)

Revision history for this message
Linda (linda-nordstrom) said :
#5

Hm, no, still getting the same error message..
Now running SikulixIDE 1.1.0 (2015-06-16_01:00nightly)

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

could you please paste the statements you used.

Revision history for this message
Linda (linda-nordstrom) said :
#7

I just copied your code and ran it, nothing else;

bs = App("Safari")

bs.open() # open and focus
bs.focus() # has the same effects as open() on Mac currently

bs.close() # close the app

--------------------------------------------------------------------------------

Also tried with "Safari.app" - same result.

bs.focus() does not throw the error, but it only works when app is minimized or behind another window, not when it's closed, then I get the same result as in original post (icon jumps in dock, then nothing happens)

bs.close() works fine.

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

Ok, confirmed.

Since I am testing from inside NetBeans, I did not realize, that it is not working, when you start SikuliX.app normally.
(on OSX 10.10 it works, since internally the open is implemented differently)

Until I found the reason for this odd difference, you should start the IDE from a Terminal session using:
<path-to>/runsikulix -c

Be aware: output goes to the Terminal.

or you might use the IDE normally, but run the script from the Terminal
<path-to>/runsikulix -r <path-to>/script.sikuli

Revision history for this message
Linda (linda-nordstrom) said :
#9

Thank you, the workaround works fine!

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

With the latest build (2015-06-19) you have the option to easily start the IDE as "non-application"

After having moved the SikuliX.app to /Applications use the provided command scripts

- doubleclick runsikulix
- in a Terminal use runsikulix (if you want to provide parameters)
- in a Terminal use /Applications/SikuliX.app/run (equivalent to runsikulix)

running scripts from the so started IDE behave the same as when run from command line.

Can you help with this problem?

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

To post a message you must log in.