Esempio n. 1
0
 def scroll(self, value):
     self.debug('Scroll to: %d' % value, DebugLevel.High)
     # save mouse position
     mouse_position = tools.get_mouse_position()
     if self.game_location:
         # get game center
         x, y = tools.coordinates_center(self.game_location)
         self.sleep(1)
     else:
         x, y = (None, None)
     # scroll
     tools.scroll_to(value, x, y)
     # wait for scroll to end
     self.sleep(1)
     # get back mouse to initial position
     tools.move_mouse_to(mouse_position)
Esempio n. 2
0
	def wait_for_click(self, callback, game_location=None):
		# wait for click
		tools.wait_for_mouse_event('left_down')
		# get mouse position & screen size
		x, y = tools.get_mouse_position()
		width, height = tools.get_screen_size()
		# get pixel color
		color = tools.get_pixel_color(x, y)
		# adjust location to game window
		if game_location is not None:
			# get game area location
			game_x, game_y, game_width, game_height = game_location
			#print('x: %d, y: %d, game_x: %d, game_y: %d, game_width: %d, game_height: %d' % (x, y, game_x, game_y, game_width, game_height))
			# scale to game area
			if tools.position_is_inside_bounds(x, y, game_x, game_y, game_width, game_height):
				# position is inside game area, so we fit x & y to it
				x = x - game_x
				y = y - game_y
				width = game_width
				height = game_height
		# execute callback
		GObject.idle_add(callback, (x, y, width, height, color))