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
-
down
(contact_id, x, y, pressure)[source]¶ add minitouch command: ‘d <contact_id> <x> <y> <pressure> ‘
-
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:
-