SwitchApp not giving menu headers?

Asked by Marianne Murray

Hi!

I'm using Sikuli on Mac with and iPhone Simulator and I want to add in a low memory message from the emulator...

To do so i have to click on the emulator and select Hardware > Simulate Memory Warning...

I'm running Sikuli from the window (not command line)

and I've been playing around with these 2 lines of code - i don't *think* i need the first, but...

Simulator=("/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app")
memory=(switchApp("Simulator"), click(middle), wait(1), click("Hardware.png"), wait(1), click("Memory.png"))

Is the problem that it's a .app, not a .exe?

When I'm running the script I never see the menu for the simulator...

Thanks!

marianne

Question information

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

Python basics:
-- on statement - one line
-- statements on the same line separated by semicolon ;
-- with if, else, while, for and def you need to know the meaning of indentation / dedentation
-- comments after a #

--- your first line
Simulator="/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"

# no need to bracket the string

--- your second line
memory=(switchApp("Simulator"), click(middle), wait(1), click("Hardware.png"), wait(1), click("Memory.png"))

# it makes an immutable list of the results of the function calls and assigns it to the variable memory. There is no guarantee for the sequence. Guess that is not your intention ;-)

# using one statement - one line:
switchApp("Simulator")
if not exists("some-image-to-knoe-the-emu-is-ready", 10): # the image has to be replaced by it's capture
    popup("Sorry, not there within 10 seconds"); exit()
# now your simulator has focus
click(middle) # what the hell is middle? Should be an image-path-string, a region or a location.
# if it should be the center of screen:
click(getCenter())
wait(1) # waits one second
click("Hardware.png") # how did you create Hardware.png? where is it?
wait(1)
click("Memory.png") # how did you create Memory.png? where is it?

Your "2-liner" script should have worked, since it is syntactically ok. It should have brought one of the following errors
--- file not found
--- middle not known

--- One more thing
click(getCenter())
wait(1)
click("Hardware.png")

This is a typical sequence, that might work, but sometimes fail, because waiting 1 second was not enough.
I prefer:
click("some-image")
if not exists("some-other-image", 10):
   popup("we have a problem"); exit() # does not make sense to go on with the script
click(getLastMatch()) # the location of last find is preserved

May be a good idea to have a look at the Complete Guide to Sikuli (http://sikuli.org/trac/wiki/reference-0.10)

Revision history for this message
Marianne Murray (qualitycurls) said :
#2

When i run Sikuli the top bar on the mac always reads "Sikuli IDE" and i don't see the Menu items for the iPhone Simulator which i need to in order to simulate the low memory conditions (a menu option within the simulator application).

So in an attempt to get around it i put in a key combo shortcut... ctrl+c which works in the simulator, but not from Sikuli as the app is not in focus...

So it seems to work if i click the top of the simulator app, then call the key combo shortcut...

def MEMORY():
   click("iPhone.png") #stored image of a piece that always exists in the emulator
   type("c", KEY_CTRL)
   wait(2)

i never did get switchApp to work as i expected, but i'm able to bypass that :)