Welcome to pyminitouch’s documentation!

CommandBuilder

class pyminitouch.actions.CommandBuilder[source]

Bases: object

Build command str for minitouch.

You can use this, to custom actions as you wish:

with safe_connection(_DEVICE_ID) as connection:
    builder = CommandBuilder()
    builder.down(0, 400, 400, 50)
    builder.commit()
    builder.move(0, 500, 500, 50)
    builder.commit()
    builder.move(0, 800, 400, 50)
    builder.commit()
    builder.up(0)
    builder.commit()
    builder.publish(connection)

use d.connection to get connection from device

append(new_content)[source]
commit()[source]

add minitouch command: ‘c ‘

down(contact_id, x, y, pressure)[source]

add minitouch command: ‘d <contact_id> <x> <y> <pressure> ‘

move(contact_id, x, y, pressure)[source]

add minitouch command: ‘m <contact_id> <x> <y> <pressure> ‘

publish(connection)[source]

apply current commands (_content), to your device

reset()[source]

clear current commands (_content)

up(contact_id)[source]

add minitouch command: ‘u <contact_id> ‘

wait(ms)[source]

add minitouch command: ‘w <ms> ‘

MNTDevice

class pyminitouch.actions.MNTDevice(device_id)[source]

Bases: object

minitouch device object

Sample:

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
# 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=50)

# extra functions ( their names start with 'ext_' )
device.ext_smooth_swipe([(100, 100), (400, 400), (200, 400)], duration=500, pressure=50, part=20)

# stop minitouch
# when it was stopped, minitouch can do nothing for device, including release.
device.stop()
ext_smooth_swipe(points, pressure=100, duration=None, part=None, no_down=None, no_up=None)[source]

smoothly swipe between points, one by one it will split distance between points into pieces

before:

points == [(100, 100), (500, 500)]
part == 8

after:

points == [(100, 100), (150, 150), (200, 200), ... , (500, 500)]
Parameters:
  • points
  • pressure
  • duration
  • part – default to 10
  • no_down – will not ‘down’ at the beginning
  • no_up – will not ‘up’ at the end
Returns:

reset()[source]
start()[source]
stop()[source]
swipe(points, pressure=100, duration=None, no_down=None, no_up=None)[source]

swipe between points, one by one

Parameters:
  • points – [(400, 500), (500, 500)]
  • pressure – default == 100
  • duration
  • no_down – will not ‘down’ at the beginning
  • no_up – will not ‘up’ at the end
Returns:

tap(points, pressure=100, duration=None, no_up=None)[source]

tap on screen, with pressure/duration

Parameters:
  • points – list, looks like [(x1, y1), (x2, y2)]
  • pressure – default == 100
  • duration
  • no_up – if true, do not append ‘up’ at the end
Returns:

MNTConnection

class pyminitouch.connection.MNTConnection(port)[source]

Bases: object

manage socket connection between pc and android

disconnect()[source]
send(content)[source]

send message and get its response

Indices and tables