pydotool
A ydotool client implemented in Python. The aim of pydotool is to write automation scripts in an easy way.
Usage
- click event
- key event
- mouse move event
- type characters
How to Use
-
Install ydotoold. you may install it from your package manager, or build it from source.
-
Install
pydotool.pip install python-ydotool -
Write your automation script. Call
initonce in your program to connect toydotoold
import pydotool
pydotool.init()
If you use another ydotoold socket than the default one (/tmp/.ydotool_socket), you can provide it in environment variable YDOTOOL_SOCKET, or pass it to init()
pydotool.init("/run/ydotoold/socket")
How to Implement the Examples in ydotool
Switch to tty1 (Ctrl+Alt+F1), wait 2 seconds, and type some words:
import time
from pydotool import KEY_F1, KEY_LEFTALT, KEY_LEFTCTRL, key_combination, init, type_string
init() # call only once before using pydotool
key_combination([KEY_LEFTCTRL, KEY_LEFTALT, KEY_F1])
time.sleep(2)
type_string("echo Hey guys. This is Austin.")
Close a window in graphical environment (Alt+F4):
from pydotool import KEY_F4, KEY_LEFTALT
key_combination([KEY_LEFTALT, KEY_F4])
Relatively move mouse pointer to -100,100:
from pydotool import mouse_move
mouse_move((100, 100))
Move mouse pointer to 100,100:
mouse_move((100, 100), True)
Mouse right click:
from pydotool import right_click
right_click()
Mouse repeating left click:
from pydotool import click_sequence, ClickEnum
click_sequence([ClickEnum.LEFT_CLICK] * 5)
stdin is not natively supported, but you can implement it with python stdin.
Advanced Usage
There is no delay in pydotool API after the last event emitted.
for i in range(5):
left_click()
if i != 4:
time.sleep(0.025)
# above code is equivalent to
click_sequence([ClickEnum.LEFT_CLICK] * 5)
Customize the delay time:
# Each click event is combined with "press" and "release", so there are totally 10 ydotool events, and 9 delays between each two consecutive events.
# the 9 delays are 10ms, 20ms, ..., 90ms.
click_sequence([ClickEnum.LEFT_CLICK] * 5, delay_sequence=list(range(10, 100, 10)))
Complex key operations:
# Ctrl+K and Ctrl+D without releasing Ctrl
key_seq([(KEY_LEFTCTRL, DOWN), (KEY_K, DOWN), (KEY_K, UP), (KEY_D, DOWN), (KEY_D, UP), (KEY_LEFTCTRL, UP)])
Control the press time when typing:
# Type "abcde", but hold 1 sec for each character.
# Note that long press may generate more content than expected.
type_string("abcde", hold_delay_ms=1000, each_char_delay_ms=20)
# possible output:
# aaaaaaaaaaaabbbbbbbbbbbccccccccccccddddddddddddeeeeeeeeeeee
Long press key combination:
# Press Alt+F4 for 3 secs. Can close most of the apps. Not recommended to try this.
key_combination([KEY_LEFTALT, KEY_F4], press_ms=3000)
Using the low level API to send event:
# directly send an event using uinput_emit()
uinput_emit(EV_REL, REL_Y, 100, True) # move 100 in y direction
Metadata
Release files for python-ydotool 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_ydotool-1.1.1.tar.gz | 40.3 kB | Without provenance | Details for python_ydotool-1.1.1.tar.gz |
Built distributions (wheels)
Total release size: 155.7 kB
Release files / python_ydotool-1.1.1.tar.gz
| Download URL | python_ydotool-1.1.1.tar.gz |
|---|---|
| Size | 40.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9b7c521998c7647b49e91b0893c99dbfe0d14d8523cfc7cadf90b3166336ec5
|
|
BLAKE2b-256 checksum How to use checksums |
4eb0b969ac74040ea4510321a31247588b64cc257acd2ce95e6269d01314f4bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / python_ydotool-1.1.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | python_ydotool-1.1.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 28.8 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
8ae214b31c447bd8a89aca6b45882530fd2c498a6e5e59140453cb22bb77e75c
|
|
BLAKE2b-256 checksum How to use checksums |
d2725222cef47aad7221f29a213e5083cc986dd7cfa39f421b59b2bbd68e47ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / python_ydotool-1.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | python_ydotool-1.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 28.9 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
2e46676d117e398a658a77b62289686f2bcb66e25ca382e6f1872bbc80007e4d
|
|
BLAKE2b-256 checksum How to use checksums |
34c80d9aa2103ee00a188f74bd51e45c9c23b8a66cc94f99a2c714d539dc745d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / python_ydotool-1.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | python_ydotool-1.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 28.8 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
de2d5e56b1646c516fbe036c2576e59112a582e471df40f93feb0df3534f03df
|
|
BLAKE2b-256 checksum How to use checksums |
3875aff189539c3c149da769a90b368572b58bb379d4080219dc4e7d4c6b8473
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / python_ydotool-1.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | python_ydotool-1.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 28.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
300c6ea1684d734723971d4870a02204827b97ce31b0d9fd6e887980ae1af1ea
|
|
BLAKE2b-256 checksum How to use checksums |
b24a8152ebdad79949adfb20835decaaa89f18ecf1b9a588a26a183db60bfe9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for python-ydotool 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.