https://github.com/commandcracker/display-server-interactions
DSI allows you to perform basic interactions on your display server, like screenshotting a window or sending input to it.
https://github.com/commandcracker/display-server-interactions
ctypes input python-library python3 screen screen-capture screen-recorder screenshot
Last synced: 3 months ago
JSON representation
DSI allows you to perform basic interactions on your display server, like screenshotting a window or sending input to it.
- Host: GitHub
- URL: https://github.com/commandcracker/display-server-interactions
- Owner: Commandcracker
- License: apache-2.0
- Created: 2022-05-24T19:09:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T12:43:47.000Z (over 2 years ago)
- Last Synced: 2025-01-07T22:10:07.556Z (10 months ago)
- Topics: ctypes, input, python-library, python3, screen, screen-capture, screen-recorder, screenshot
- Language: Python
- Homepage: https://pypi.org/project/display-server-interactions/
- Size: 110 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Display Server Interactions
[](https://pypi.org/project/display-server-interactions/)
[](https://display-server-interactions.readthedocs.io/en/latest)
[](https://pepy.tech/project/display-server-interactions)
[](https://pypi.org/project/display-server-interactions/)
[](https://github.com/Commandcracker/display-server-interactions/blob/main/LICENSE.txt)
[](https://github.com/Commandcracker/display-server-interactions/stargazers)
[](https://github.com/Commandcracker/display-server-interactions/network)
[](https://github.com/Commandcracker/display-server-interactions/issues)
[](https://github.com/Commandcracker/display-server-interactions/actions/workflows/pypi-publish.yml)
DSI allows you to perform basic interactions on your display server, like screenshotting a window or sending input to it.
Currently, DSI only supports X11/Xorg (GNU/Linux) and Windows but it aims to be cross-platform.
**WARNING: Please Do not use DSI in production, because it's currently in development!**
## Quick overview
Look at the [documentation](https://display-server-interactions.readthedocs.io/en/latest/) for moor information
### Get a window
```python
from display_server_interactions import DSI
dsi = DSI()
window = dsi.get_active_window()
```
### Get basic window information
```python
print("Active window: ")
print("\tName: {}".format(window.name))
print("\tPID: {}".format(window.pid))
```
### Take a screenshot of the window
```python
import cv2
import numpy as np
img = np.array(window.get_image())
cv2.imshow(f'Screenshot of "{window.name}"', img)
while True:
if cv2.waitKey(1) & 0xFF == ord('q'):
break
```
### Sending keys to a window
```python
window.send_str("Hello World")
```
### Move the mouse pointer
```python
window.warp_pointer(x=42, y=73)
```
### Sending mouse clicks
```python
window.send_mouse_click(x=42, y=73)
```