class ActionPlayer(object): def __init__(self, device_id: str): self.device_id = device_id self.mnt = MNTDevice(device_id) def stop(self): self.mnt.stop() def tap(self, point: (list, tuple), duration=100): x, y = map(int, point) logger.info('Tap point: ({}, {})'.format(x, y)) self.mnt.tap([(x, y)], duration=duration) # add 50ms for syncing status time.sleep((duration + 50) / 1000) def long_tap(self, point: (list, tuple), duration: int = 1000): self.tap(point, duration) def swipe(self, point1: (list, tuple), point2: (list, tuple), duration: int = 1, part: int = 10): self.mnt.ext_smooth_swipe([point1, point2], duration=duration, part=part) time.sleep((duration + 50) / 1000)
class ActionPlayer(object): """ base, low level API here """ def __init__(self, device_id: str): self.device_id = device_id self.mnt = MNTDevice(device_id) self.cmd_builder = CommandBuilder() def stop(self): self.mnt.stop() def tap(self, point: (list, tuple), duration: int = 100, no_up: bool = None): self.mnt.tap([point], duration=duration, no_up=no_up) def short_tap(self, point: (list, tuple), *args, **kwargs): self.tap(point, duration=100, *args, **kwargs) def long_tap(self, point: (list, tuple), *args, **kwargs): self.tap(point, duration=1000, *args, **kwargs) def swipe(self, point1: (list, tuple), point2: (list, tuple), duration: int = None, part: int = None, no_down: bool=None, no_up: bool=None): if not duration: duration = 5 if not part: part = 50 self.mnt.ext_smooth_swipe( [point1, point2], duration=duration, part=part, no_down=no_down, no_up=no_up, ) def fast_swipe(self, point1: (list, tuple), point2: (list, tuple), *args, **kwargs): self.swipe(point1, point2, duration=5, part=100, *args, **kwargs) def slow_swipe(self, point1: (list, tuple), point2: (list, tuple), *args, **kwargs): self.swipe(point1, point2, duration=50, part=100, *args, **kwargs)
import time from pyminitouch import safe_connection, safe_device, MNTDevice _DEVICE_ID = '4df189487c7b6fef' device = MNTDevice(_DEVICE_ID) # single-tap device.tap([(400, 600)]) # multi-tap device.tap([(400, 400), (600, 600)]) # set the pressure, default == 100 device.tap([(400, 600)], pressure=50) # long-time-tap # for long-click, you should control time delay by yourself # because minitouch return nothing when actions done # we will never know the time when it finished device.tap([(400, 600)], duration=1000) time.sleep(1) # swipe device.swipe([(100, 100), (500, 500)]) # of course, with duration and pressure device.swipe([(100, 100), (400, 400), (200, 400)], duration=500, pressure=59) # stop minitouch # when it was stopped, minitouch can do nothing for device, including release. device.stop()
from pyminitouch import MNTDevice _DEVICE_ID = 'FJH5T18A31026410' device = MNTDevice(_DEVICE_ID) # single-tap device.tap([(400, 600)]) # multi-tap device.tap([(400, 400), (600, 600)]) # set the pressure, default == 100 device.tap([(400, 600)], pressure=50) # 可以直接用简洁的API调用minitouch提供的强大功能! # 在使用完成后,需要显式调用stop方法将服务停止 device.stop()
def __init__(self, device_id: str): self.device_id = device_id self.mnt = MNTDevice(device_id) self.cmd_builder = CommandBuilder()
from loguru import logger import pygame from pyminitouch import MNTDevice import time from touch_event_manager import TouchEventManager import widgets from _DEVICE_ID import _DEVICE_ID device = MNTDevice(_DEVICE_ID) # Register the buttons tem = TouchEventManager(device) operation_start_button_1 = widgets.Button(tem, name='operation_start_1', center=(985, 2160 - 1938)) operation_start_button_2 = widgets.Button(tem, name='operation_start_2', center=(763, 2160 - 1772)) give_up_operation_button = widgets.Button(tem, name='give_up_operation', center=(763, 2160 - 775)) # Profiles p_OF_F4 = {'time': 138} p_OF_8 = {'time': 180}
import pygame from pyminitouch import MNTDevice import time from touch_event_manager import TouchEventManager import widgets from _DEVICE_ID import _DEVICE_ID device = MNTDevice(_DEVICE_ID) tem = TouchEventManager(device) ################ Define Widgets ################ # Buttons reload_button = widgets.Button( tem, name='reload', center=(1080 - 1005, 1701) ) jump_button = widgets.Button( tem, name='jump', center=(1080 - 754, 2075) ) crouch_button = widgets.Button( tem, name='crouch',
from pyminitouch import safe_connection, safe_device, MNTDevice, CommandBuilder _DEVICE_ID = "123456F" # --- device = MNTDevice(_DEVICE_ID) # It's also very important to note that the maximum X and Y coordinates may, but usually do not, match the display size. # so you need to calculate position by yourself, and you can get maximum X and Y by this way: print("max x: ", device.connection.max_x) print("max y: ", device.connection.max_y) # single-tap device.tap([(400, 600)]) # multi-tap device.tap([(400, 400), (600, 600)]) # set the pressure, default == 100 device.tap([(400, 600)], pressure=50) # long-time-tap device.tap([(400, 600)], duration=2000) # and no up at the end. you can continue your actions after that. default to false device.tap([(400, 600)], duration=2000, no_up=True) # swipe device.swipe([(100, 100), (500, 500)]) # of course, with duration and pressure device.swipe([(100, 100), (400, 400), (200, 400)], duration=500, pressure=50)
def __init__(self, device_id: str): self.device_id = device_id self.mnt = MNTDevice(device_id) self.cmd_builder = CommandBuilder() logger.info("action player inited")
def __init__(self, ID): MNTDevice.__init__(self, ID)
def __init__(self, device_id: str): self.device_id = device_id self.mnt = MNTDevice(device_id)