Windows macro input API — keyboard, mouse, window & pixel
Project description
urmacropkg
Windows macro input API — keyboard, mouse, window & pixel operations.
Uses SendInput / win32 for real input events compatible with games (DirectInput, raw input, anti-cheat).
Install
pip install urmacropkg
With OCR support (Windows native):
pip install urmacropkg[ocr]
Usage
from urmacro import *
# Keyboard
press('a')
press('ctrl', hold=True)
press('c')
release('ctrl')
write("hello world")
# Mouse
left_click()
smooth_move(960, 540, duration=0.5)
send_input_delta(100, 0) # raw relative move (game cameras)
# Window
focus_window("Notepad")
focus_window("MyGame", full_scale=True)
# Pixel
color = get_pixel_color(100, 200)
if check_pixel_color(500, 300, r=255, g=0, b=0, tolerance=15):
print("red pixel found")
pos = find_color(0, 0, 1920, 1080, r=0, g=255, b=0)
# Interruptible sleep (for macro loops)
def my_macro(get_active_status):
while get_active_status():
press('space')
if not sleep_interruptible(1.0, get_active_status):
return
API Reference
Keyboard
| Function | Description |
|---|---|
press(key) |
Press and release a key ('a', 'f1', 'enter', 'space', '\\'...) |
press(key, hold=True) |
Hold a key down |
release(key) |
Release a held key |
release_all() |
Release all held keys and mouse buttons |
write(text, delay=0.05) |
Type a string (Unicode, supports accents) |
Mouse
| Function | Description |
|---|---|
left_click() / right_click() |
Click |
left_click(hold=True) |
Hold mouse button |
release_left_click() / release_right_click() |
Release held button |
move(x, y) |
Instant cursor warp (cosmetic) |
send_input_move(x, y) |
Absolute move via SendInput (UI clicks) |
send_input_delta(dx, dy) |
Relative move via SendInput (game cameras) |
smooth_move(x, y, duration=0.4) |
Smooth Bezier move via SendInput |
smooth_move(dx, dy, relative=True) |
Smooth relative move |
Window
| Function | Description |
|---|---|
find_window(title, partial=True) |
Returns (hwnd, title) or (None, None) |
focus_window(title, partial=True, full_scale=False) |
Bring window to foreground |
Pixel & Screen
| Function | Description |
|---|---|
get_pixel_color(x, y) |
Returns (R, G, B) or None |
check_pixel_color(x, y, r, g, b, tolerance=10) |
Color match with tolerance |
find_color(x, y, w, h, r, g, b, tolerance=10) |
Find first pixel of color in region |
find_color_bounds(x, y, w, h, ref_x, ref_y) |
Bounding box of a color zone |
screenshot_region(x, y, w, h) |
PIL Image of a screen region |
read_text(x, y, w, h, lang='fr') |
OCR via Windows native API (requires [ocr]) |
get_cursor_pos() |
Returns (x, y) |
get_screen_size() |
Returns (width, height) |
get_zone_center(x1, y1, x2, y2) |
Returns (cx, cy) |
Timing
| Function | Description |
|---|---|
sleep_interruptible(seconds, get_active_status) |
Sleep that returns False if macro is stopped |
All pixel functions accept an optional window_title argument — coordinates are then relative to the window's client area.
Requirements
- Windows 10/11
- Python 3.10+
pywin32Pillowwinocr(optional, for OCR)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file urmacropkg-1.0.0.tar.gz.
File metadata
- Download URL: urmacropkg-1.0.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be5bf982d1f381ef5442642e009b5222646ef009a29b236b7823e6c452d749f6
|
|
| MD5 |
053972ee5e6d3f2ade155b8077ab1657
|
|
| BLAKE2b-256 |
03df095b0521d8f39fc24c25f1ea6a9d0fc69800bc3487e85178707dffbfbc97
|
Provenance
The following attestation bundles were made for urmacropkg-1.0.0.tar.gz:
Publisher:
publish.yml on Yxoo/urmacropkg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
urmacropkg-1.0.0.tar.gz -
Subject digest:
be5bf982d1f381ef5442642e009b5222646ef009a29b236b7823e6c452d749f6 - Sigstore transparency entry: 998696766
- Sigstore integration time:
-
Permalink:
Yxoo/urmacropkg@2b8787f69169f90fc2455819a32d75c637d56d19 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Yxoo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2b8787f69169f90fc2455819a32d75c637d56d19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file urmacropkg-1.0.0-py3-none-any.whl.
File metadata
- Download URL: urmacropkg-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ea969754d4482e2fb2fb4a5a912f73cbedac555222f5856215a2c8f4b9a2a2f
|
|
| MD5 |
a3820da38f47f1b7bd26bc023d545698
|
|
| BLAKE2b-256 |
be11ca4d06e8764a4a2c60bca04a9aca79c7a49689db62bd6ce21d465c6aed39
|
Provenance
The following attestation bundles were made for urmacropkg-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Yxoo/urmacropkg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
urmacropkg-1.0.0-py3-none-any.whl -
Subject digest:
3ea969754d4482e2fb2fb4a5a912f73cbedac555222f5856215a2c8f4b9a2a2f - Sigstore transparency entry: 998696781
- Sigstore integration time:
-
Permalink:
Yxoo/urmacropkg@2b8787f69169f90fc2455819a32d75c637d56d19 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Yxoo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2b8787f69169f90fc2455819a32d75c637d56d19 -
Trigger Event:
push
-
Statement type: