test.sikuli\test.sikuli

(Download this script)
setThrowException(False)
restStop = Pattern().targetOffset(0,20)

def skipButton():
   s = 0
   while exists(,0):
      s = s + 1
      click()
      if s == 10:
         while exists(,0):
            s = s + 1
            click()
            if s == 20:
               refreshPage()
   s = 0
   while exists(,0):
      s = s + 1
      click()
      if s == 10:
         while exists(,0):
            s = s + 1
            click()
            if s == 20:
               refreshPage()
   if exists(Pattern().similar(0.90),0):
      helpingtimer = 0.5
   else:
      helpingtimer = 0
   click(Pattern().similar(0.90))
   wait(helpingtimer*4)
   click(Pattern().similar(0.90))
   wait(helpingtimer)
   click()
   wait(helpingtimer)
   click()
   while exists(,0) and not exists(Pattern().similar(0.90),0):
      click()
   rest()

def refreshPage():
   click(Pattern().targetOffset(-20,0))
   wait(3)
   type(Key.F5)
   wait(Pattern().targetOffset(-43,0), 60)
   click(getLastMatch())
   for i in range(1, 6):
      type(Key.DOWN)
      wait(0.2)
   wait(,30)
   wait(,5)
   rx=getLastMatch().getX()-3
   ry=getLastMatch().getY()-1
   rw=760
   rh=650
   setROI(rx,ry,rw,rh)
   skipButton()
   rest()
   relocate()

def relocate():
   #random number 1 through 4
   #make each number a direction
   #random distance (time to keep pressed)
   direction = 1
   distance = 85
   x=0
   y=0
   if direction==1:
      x=-distance
   if direction==2:
      y=-distance
   if direction==3:
      x=distance
   if direction==4:
      y=distance
   dragDrop(Pattern().targetOffset(0,150), Pattern().targetOffset(x,150+y))

def rest():
   hover(restStop)

def clickAll(tag):
   if exists(tag,0):
      skipButton()
      while exists(tag,0):
         click(tag)
         skipButton()

def buyContract(tag):
   if exists(tag,0):
      skipButton()
      while exists(tag,0):
         click(tag)
         click()
         skipButton()

switchApp("Social City on Facebook")
#refreshPage()
a = 0
while True:
   rest()

   a = a + 1
   if a == 50 or exists(Pattern().similar(0.95),0):
      refreshPage()

   skipButton()

   clickAll()
   clickAll()
   clickAll()
   if exists(,0):# or exists(,0):
      clickAll()
   buyContract()
#   if not exists("temp2.png",0):
#      clickAll("1273495703554.png")


#   sleep(10)