Beispiel #1
0
def openURL():
	"""opens website automatically if the resolution of the screen is usual ( HD or FHD ), else asks the user to open it manually"""
	width, heigth = screen.get_size()

	if heigth == 1080:
		mouse.smooth_move(200, 60)
		mouse.click(mouse.LEFT_BUTTON)
		mouse.click(mouse.LEFT_BUTTON)
		mouse.click(mouse.LEFT_BUTTON)
	elif heigth == 768:
		mouse.smooth_move(200, 60)
		mouse.click(mouse.LEFT_BUTTON)
		mouse.click(mouse.LEFT_BUTTON)
		mouse.click(mouse.LEFT_BUTTON)
	else:
		print 'Please open http://www.nytimes.com/interactive/science/rock-paper-scissors.html then type OK'
		if 'ok'.lower() == raw_input():
			print 'TY'
	time.sleep(1)

	speed = 0
	key.type_string('http',speed)
	key.tap('.', key.MOD_SHIFT)
	key.tap('6', key.MOD_SHIFT)
	key.tap('6', key.MOD_SHIFT)
	key.type_string('www.nytimes.com',speed)
	key.tap('6', key.MOD_SHIFT)
	key.type_string('interactive',speed)
	key.tap('6', key.MOD_SHIFT)
	key.type_string('science',speed)
	key.tap('6', key.MOD_SHIFT)
	key.type_string('rock-paper-scissors.html',speed)
	key.tap('6', key.MOD_SHIFT)
	key.tap(key.K_RETURN)
def refillHotbar(row):
  
  grid_step = 36
  
  #open inventory
  key.tap('i')
  time.sleep(1)
  
  #find the first pos of the hot bar
  pos = findBitmapOnScreen('MC_cornerBottle.png') 
  cornerpos = (pos[0] + grid_step/2, pos[1] + grid_step/2)
  mouse.smooth_move(cornerpos[0], cornerpos[1])
  
  for col in range(9):
    mouse.smooth_move(cornerpos[0] + (col*grid_step), 
                      cornerpos[1] - (row * grid_step))
    time.sleep(0.3)
    key.tap(str(col + 1))
    time.sleep(0.3)
    print(str(col + 1))

  #close inventory
  global drink_counter
  
  #reset the drink counter
  drink_counter = 0
  key.tap('i')
  time.sleep(1)
Beispiel #3
0
def startMatch():
    print ("startMatch")
    x = width/2
    y = height - 105 # find "Ready" button
    
    mouse.smooth_move(x, y)
    mouse.click()
    time.sleep(0.5)
Beispiel #4
0
def startMatch():
    print("startMatch")
    x = width / 2
    y = height - 105  # find "Ready" button

    mouse.smooth_move(x, y)
    mouse.click()
    time.sleep(0.5)
Beispiel #5
0
def endMatch():
    print ("startMatch")
    x = 50
    y = height - 100 # find "Leave" button
    
    mouse.smooth_move(x, y)
    mouse.click()
    time.sleep(0.5)
    mouse.click()
Beispiel #6
0
def endMatch():
    print("startMatch")
    x = 50
    y = height - 100  # find "Leave" button

    mouse.smooth_move(x, y)
    mouse.click()
    time.sleep(0.5)
    mouse.click()
def find_water_bottle():
  key.tap('i') # open inventory
  time.sleep(1)
  
  pos = findBitmapOnScreen('MC_fullBottle.png')
  mouse.smooth_move(pos[0], pos[1]) # point the bottle
  time.sleep(3)
  
  key.tap('i') # close inventory
  time.sleep(1)
Beispiel #8
0
def find_water_bottle():
    key.tap('i')  # open inventory
    time.sleep(1)

    pos = findBitmapOnScreen('MC_fullBottle.png')
    mouse.smooth_move(pos[0], pos[1])  # point the bottle
    time.sleep(3)

    key.tap('i')  # close inventory
    time.sleep(1)
Beispiel #9
0
def useTalents():
    print ("useTalents")
    x = width/2
    y = height/2
    for char in ['q', 'w', 'e', 'r', 'd', '1', '2', '3', '4', '5']:
        mouse.smooth_move(x-randint(-300,300), y-randint(200,200)) 
        key.tap(char)
        mouse.click()
        time.sleep(0.5)
        key.tap(char)
        mouse.click(mouse.RIGHT_BUTTON)
Beispiel #10
0
def useTalents():
    print("useTalents")
    x = width / 2
    y = height / 2
    for char in ['q', 'w', 'e', 'r', 'd', '1', '2', '3', '4', '5']:
        mouse.smooth_move(x - randint(-300, 300), y - randint(200, 200))
        key.tap(char)
        mouse.click()
        time.sleep(0.5)
        key.tap(char)
        mouse.click(mouse.RIGHT_BUTTON)
Beispiel #11
0
def goFight():
    print ("goFight")
    
    ###move back and forth
    # x = width/2
    # y = height/2
    # mouse.smooth_move(x-randint(100,300)*direction, y-randint(0,100)) #ahead
    # mouse.click(mouse.RIGHT_BUTTON)
    # time.sleep(5)
    # mouse.smooth_move(x+randint(50,100)*direction, y-randint(0,100)) # back
    # mouse.click(mouse.RIGHT_BUTTON)
    
    ###use mini map
    x = width-((230+250)/2) # mid btw all maps and HM
    y = height+50-((155+235)/2) # mid btw all maps and HM
    
    #unmount
    key.tap('z')
    
    direction = 1
    
    for i in range(3):
        chooseTalent()
        
        direction = direction * (-1) # toggle directions
        x1 = x - 70 * direction 
        y1 = y - randint(-10,10) # surely within maps
        #y = y - randint(0,1)*(235-155) # haunted mines offset
        
        mouse.smooth_move(x1, y1) # pos on minimap
        
        #ALT callout
        key.toggle(key.K_ALT, True)
        mouse.click()
        key.toggle(key.K_ALT, False)
        
        #mount
        key.tap('z')
        time.sleep(1.5)
        
        key.tap('a') # attack move
        mouse.click()
        time.sleep(18) # time to cross half the map
        useTalents()
Beispiel #12
0
def goFight():
    print("goFight")

    ###move back and forth
    # x = width/2
    # y = height/2
    # mouse.smooth_move(x-randint(100,300)*direction, y-randint(0,100)) #ahead
    # mouse.click(mouse.RIGHT_BUTTON)
    # time.sleep(5)
    # mouse.smooth_move(x+randint(50,100)*direction, y-randint(0,100)) # back
    # mouse.click(mouse.RIGHT_BUTTON)

    ###use mini map
    x = width - ((230 + 250) / 2)  # mid btw all maps and HM
    y = height + 50 - ((155 + 235) / 2)  # mid btw all maps and HM

    #unmount
    key.tap('z')

    direction = 1

    for i in range(3):
        chooseTalent()

        direction = direction * (-1)  # toggle directions
        x1 = x - 70 * direction
        y1 = y - randint(-10, 10)  # surely within maps
        #y = y - randint(0,1)*(235-155) # haunted mines offset

        mouse.smooth_move(x1, y1)  # pos on minimap

        #ALT callout
        key.toggle(key.K_ALT, True)
        mouse.click()
        key.toggle(key.K_ALT, False)

        #mount
        key.tap('z')
        time.sleep(1.5)

        key.tap('a')  # attack move
        mouse.click()
        time.sleep(18)  # time to cross half the map
        useTalents()
Beispiel #13
0
def do_simulation(my_images):
    can_find = False
    my_index = -1
    for my_image in my_images:
        my_index += 1
        my_rect = find_image_location_in_screen(my_image)
        if my_rect:
            can_find = True
            print(my_images_name_list[my_index] + ' at rect: ' + str(my_rect))
            sleep_random_time(min_time=my_delay_move_min,max_time=my_delay_move_max)
            mouse.smooth_move(my_rect[0],my_rect[1])
            print('Click')
            sleep_random_time(min_time=my_delay_click_min,max_time=my_delay_click_max)
            mouse.click()
            print('Move to 0,0')
            sleep_random_time(min_time=my_delay_click_min,max_time=my_delay_click_max)
            mouse.smooth_move(0,0)
            break
    if can_find is False:
        print('Not found.')
Beispiel #14
0
def do_simulation(my_images):
    can_find = False
    my_index = -1
    for my_image in my_images:
        my_index += 1
        my_rect = find_image_location_in_screen(my_image)
        if my_rect:
            can_find = True
            print(my_images_name_list[my_index] + ' at rect: ' + str(my_rect))
            sleep_random_time(min_time=my_delay_move_min,max_time=my_delay_move_max)
            mouse.smooth_move(my_rect[0],my_rect[1])
            print('Click')
            sleep_random_time(min_time=my_delay_click_min,max_time=my_delay_click_max)
            mouse.click()
            print('Move to 0,0')
            sleep_random_time(min_time=my_delay_click_min,max_time=my_delay_click_max)
            mouse.smooth_move(0,0)
            break
    if can_find is False:
        print('Not found.')
Beispiel #15
0
def executeMove(startX, startY, moveSequence):
	print(moveSequence)

	sx = x + startX * tileWidth + tileWidth/4
	sy = y + startY * tileHeight + tileHeight/4

	mouse.move(sx, sy)
	mouse.click()
	mouse.toggle(True)

	for i in range(len(moveSequence)):
		if(moveSequence[i] == 'l'):
			sx = sx - tileWidth
		if(moveSequence[i] == 'r'):
			sx = sx + tileWidth
		if(moveSequence[i] == 'u'):
			sy = sy - tileHeight
		if(moveSequence[i] == 'd'):
			sy = sy + tileHeight
		mouse.smooth_move(sx, sy)
	mouse.toggle(False)
Beispiel #16
0
def make_avalanche():
    ct = 0
    relogin = False
    while True:
        # if not relogin and datetime.now().hour == 5 and datetime.now().minute > 25:
        #     print('\n\n--------------\nRELOGIN\n\n\n')
        #     login()
        #     relogin = True

        ct += 1
        print(f'Round {ct}:')
        for i in range(4):
            print('Eating mushroom')
            key.tap(key.Code.F2)
            time.sleep(random.random() / 2)

        for i in range(7):
            if ct == 1:
                continue

            print('Making avalanche')
            key.tap(key.Code.F1)
            time.sleep(3 + random.random())
        print('...')
        key.tap(key.Code.F3)

        time.sleep(5)
        print('Using Dummy...')
        key.tap(key.Code.F4)
        time.sleep(1)
        mouse.smooth_move(870.0, 61.0)
        mouse.click()
        time.sleep(1)
        mouse.smooth_move(random.random() * 1000, random.random() * 1000)
        wait_time = 10 * 60 / 2
        # wait_time = wait_time
        print(f'Waiting {wait_time} seconds')
        time.sleep(wait_time)
Beispiel #17
0
def chooseDifficulty(difficulty):
	"""Moves the cursor to the difficulty button specified by the parameter"""
	
	width, heigth = screen.get_size()

	if heigth == 1080:
		if difficulty == 'novice':
			mouse.smooth_move(1300,710)
			time.sleep(10)
			mouse.click(mouse.LEFT_BUTTON)
		else:
			mouse.smooth_move(1300,810)
			time.sleep(10)
			mouse.click(mouse.LEFT_BUTTON)
	elif heigth == 768:
		if difficulty == 'novice':
			mouse.smooth_move(1000,630)
			time.sleep(10)
			mouse.click(mouse.LEFT_BUTTON)
		else:
			mouse.smooth_move(1000,680)
			time.sleep(10)
			mouse.click(mouse.LEFT_BUTTON)
def click_ad(pos):
  delta = 100
  mouse.smooth_move(pos[0]+delta, pos[1]+delta)
  mouse.click()
  mouse.smooth_move(pos[0], 0) # move mouse away
  
  #"find the спечели билет button"
  pos = None
  while True:
    time.sleep(1) # wait for the ads page to load 1s
    pos = findBitmapOnScreen('yatoto_specheli.png')
    if pos:
      break
    
  mouse.smooth_move(pos[0]+10, pos[1]+10)
  mouse.click()
  mouse.smooth_move(pos[0], 0) # move mouse away
    
  pos = None
  #"wait 2 seconds and look for вземи билета. if absent repeat"
  while True:
    time.sleep(2) # wait for the ads page to load 6s
    pos = findBitmapOnScreen('yatoto_specheli.png')
    if pos:
      break
    
  mouse.smooth_move(pos[0]+10, pos[1]+10)
  mouse.click()
  mouse.smooth_move(pos[0], 0) # move mouse away
  
  
  #"close the current tab with ctrl+W"
  time.sleep(2)
  key.tap('w', key.MOD_CONTROL)

  time.sleep(2)
  time.sleep(2)
#eof click_ad
  

#"presume the yatoto site is open"
autopy.alert.alert("open www.yatoto.com to start")

first_row_ads_clicked = 0
done = False

#"-main loop-"
while not done:
  
  #find the search area and click a little to the left
  pos = findBitmapOnScreen('yatoto_search.png')
  mouse.smooth_move(pos[0]-350, pos[1]+0)
  mouse.click()
  
  time.sleep(12) # wait for the ads page to load 30s
  
  #scroll down one row
  tap_count_to_scroll_one_row = 10
  for i in range(tap_count_to_scroll_one_row):
    key.tap(key.K_DOWN)
    time.sleep(0.1)
  
  coords = findBitmapOnScreen('yatoto_done.png')
  if coords != None:
    done = True
  
  coords = findBitmapOnScreen('yatoto_ad_corner.png')

#eof click_ad

#"presume the yatoto site is open"
autopy.alert.alert("open www.yatoto.com to start")

first_row_ads_clicked = 0
done = False

#"-main loop-"
while not done:

    #find the search area and click a little to the left
    pos = findBitmapOnScreen('yatoto_search.png')
    mouse.smooth_move(pos[0] - 350, pos[1] + 0)
    mouse.click()

    time.sleep(12)  # wait for the ads page to load 30s

    #scroll down one row
    tap_count_to_scroll_one_row = 10
    for i in range(tap_count_to_scroll_one_row):
        key.tap(key.K_DOWN)
        time.sleep(0.1)

    coords = findBitmapOnScreen('yatoto_done.png')
    if coords != None:
        done = True

    coords = findBitmapOnScreen('yatoto_ad_corner.png')
Beispiel #21
0
                        RUNNING = False
                        print "false"
                        return
                user32.TranslateMessage(ctypes.byref(msg))
                user32.DispatchMessageA(ctypes.byref(msg))
        finally:
            user32.UnregisterHotKey(None, 1)
Hotkey().start()
while RUNNING==True:        
#     mouse.move(273, 305)
#     mouse.click()
#     mouse.move(607, 475)
#     mouse.click()
#     mouse.move(647, 361)
#     mouse.click()
    mouse.smooth_move(949,732)
    mouse.click()
    t=time.clock()
    while time.clock()<t+1.00:
        pass
    
    mouse.smooth_move(293, 305)
    mouse.click()
    t=time.clock()
    while time.clock()<t+1.00:
        pass
    
    mouse.smooth_move(627, 475)
    mouse.click()
    while time.clock()<t+3.00:
        pass
          minIndex[0] = indices[0]
        if indices[1] < minIndex[1]:
          minIndex[1] = indices[1]
        if indices[0] > maxIndex[0]:
          maxIndex[0] = indices[0]
        if indices[1] > maxIndex[1]:
          maxIndex[1] = indices[1]
        # im.save("test_%i_%i.png"%(x,y))
        
        fullArray[indices[0],indices[1]] = arrayNumbers.index(ar) - 1
        print indices, arrayNumbers.index(ar) - 1

  # imagehash.average_hash(meinsweeper)
  print minIndex, maxIndex
  usefulArray = fullArray[minIndex[0]:maxIndex[0],minIndex[1]:maxIndex[1]]
  print usefulArray.shape
  for x in range(1, usefulArray.shape[0]-1):
    for y in range(1, usefulArray.shape[1]-1):
      
      mn = mineSweepNine(usefulArray[x-1:x+2,y-1:y+2]) 
      if mn.leftClick or mn.rightClick:
        changedSomething = True
        p = [offset[0] + (minIndex[0]+x)*tileSize, offset[1] + (minIndex[1]+y)*tileSize]
        print mn.array
        ms.smooth_move(p[0]/2+tileInterior/2,p[1]/2+tileInterior/2)
        if mn.leftClick:
          ms.click(ms.LEFT_BUTTON)
          ms.click(ms.LEFT_BUTTON)
        else:
          ms.click(ms.RIGHT_BUTTON)
  time.sleep(0.5)
def moveMouse(point):
    print 'moving to %s, %s' % (point[0], point[1])
    mouse.smooth_move(point[0], point[1])
Beispiel #24
0
          minIndex[0] = indices[0]
        if indices[1] < minIndex[1]:
          minIndex[1] = indices[1]
        if indices[0] > maxIndex[0]:
          maxIndex[0] = indices[0]
        if indices[1] > maxIndex[1]:
          maxIndex[1] = indices[1]
        # im.save("test_%i_%i.png"%(x,y))
        
        fullArray[indices[0],indices[1]] = arrayNumbers.index(ar) - 1
        print indices, arrayNumbers.index(ar) - 1

  # imagehash.average_hash(meinsweeper)
  print minIndex, maxIndex
  usefulArray = fullArray[minIndex[0]:maxIndex[0],minIndex[1]:maxIndex[1]]
  print usefulArray.shape
  for x in range(1, usefulArray.shape[0]-1):
    for y in range(1, usefulArray.shape[1]-1):
      
      mn = mineSweepNine(usefulArray[x-1:x+2,y-1:y+2]) 
      if mn.leftClick or mn.rightClick:
        changedSomething = True
        p = [offset[0] + (minIndex[0]+x)*64, offset[1] + (minIndex[1]+y)*64]
        print mn.array
        ms.smooth_move(p[0]/2+20,p[1]/2+20)
        if mn.leftClick:
          ms.click(ms.LEFT_BUTTON)
          ms.click(ms.LEFT_BUTTON)
        else:
          ms.click(ms.RIGHT_BUTTON)
  time.sleep(0.5)
def click_ad(pos):
    delta = 100
    mouse.smooth_move(pos[0] + delta, pos[1] + delta)
    mouse.click()
    mouse.smooth_move(pos[0], 0)  # move mouse away

    #"find the спечели билет button"
    pos = None
    while True:
        time.sleep(1)  # wait for the ads page to load 1s
        pos = findBitmapOnScreen('yatoto_specheli.png')
        if pos:
            break

    mouse.smooth_move(pos[0] + 10, pos[1] + 10)
    mouse.click()
    mouse.smooth_move(pos[0], 0)  # move mouse away

    pos = None
    #"wait 2 seconds and look for вземи билета. if absent repeat"
    while True:
        time.sleep(2)  # wait for the ads page to load 6s
        pos = findBitmapOnScreen('yatoto_specheli.png')
        if pos:
            break

    mouse.smooth_move(pos[0] + 10, pos[1] + 10)
    mouse.click()
    mouse.smooth_move(pos[0], 0)  # move mouse away

    #"close the current tab with ctrl+W"
    time.sleep(2)
    key.tap('w', key.MOD_CONTROL)

    time.sleep(2)
 def click_chess(self, x, y):
     pos_x, pos_y = self.get_chess_postion(x, y)
     mouse.smooth_move(pos_x, pos_y)
     mouse.toggle(True)
     time.sleep(1)
     mouse.toggle(False)
Beispiel #27
0
def act(guess):
	"""moves the cursor to the appropriate area of the screen"""
	
	width, heigth = screen.get_size()

	if heigth == 1080:
		if guess == 'r':
			mouse.smooth_move(660,580)
			mouse.click(mouse.LEFT_BUTTON)
		elif guess == 'p':
			mouse.smooth_move(740,580)
			mouse.click(mouse.LEFT_BUTTON)
		elif guess == 's':
			mouse.smooth_move(560,580)
			mouse.click(mouse.LEFT_BUTTON)
	elif heigth == 768:	
		if guess == 'r':
			mouse.smooth_move(350,480)
			mouse.click(mouse.LEFT_BUTTON)
		elif guess == 'p':
			mouse.smooth_move(500,480)
			mouse.click(mouse.LEFT_BUTTON)
		elif guess == 's':
			mouse.smooth_move(220,480)
			mouse.click(mouse.LEFT_BUTTON)