pymacro
PyMacro is a partial wrapper around pyautogui. PyMacro can automate your tasks all inside of Python - give it a try!
Features
- Object oriented
- Extra utility functions
- Asynchronous support
Installation
PyMacro can be easily downloaded with PIP:
pip install pymacro
You can install the latest version from this repository, too:
pip install git+https://github.com/jay3332/PyMacro
Example Usage
Basic Usage
from pymacro import Macro
macro = Macro()
macro.type("Hello, world!", interval=.15)
macro(wait=2)
Mouse/keyboard Macros
from pymacro import Macro
macro = Macro()
macro.move_mouse_relative((0, 50), seconds=0.5)
macro.click()
macro.key_press("enter")
macro(wait=0.5)
Repeat Macro Indefinitely
from pymacro import Macro
macro = Macro()
macro.click()
macro(wait=0.5, repeat=0, delay=0.1)
# Wait 0.5 seconds before starting the macro.
# Repeating 0 times tells pymacro to repeat this macro forever without end.
# Delay of 0.1 means to wait 0.1 seconds between every iteration of the loop.
Async Usage
import asyncio
from pymacro import Macro
macro = Macro()
macro.type("Hello, world!", interval=.15)
async def run_macro():
await macro.async_run(wait=2)
asyncio.run(run_macro())
Executing Functions
from pymacro import Macro
def fn():
print("This function is running.")
macro = Macro()
macro.execute(fn, times=5) # execute this function 5 times
macro()
Multi-tasking
Because PyMacro has asynchrounous support, it is possible to run two macros at once in the same program.
Multiple Macros at once (asyncio)
import pymacro
import asyncio
macro1 = pymacro.Macro()
macro2 = pymacro.Macro()
def print_one_to_ten():
for i in range(1, 11):
print(i)
macro1.execute(print_one_to_ten)
macro2.execute(print_one_to_ten)
loop = asyncio.get_event_loop()
loop.create_task(macro1.async_run())
loop.create_task(macro2.async_run())
Multiple Macros at once (threading)
âš This is not recommended - use asyncio if possible.
import pymacro
import threading
macro1 = pymacro.Macro()
macro2 = pymacro.Macro()
def print_one_to_ten():
for i in range(1, 11):
print(i)
macro1.execute(print_one_to_ten)
macro2.execute(print_one_to_ten)
runner1 = threading.Thread(target=macro1.run)
runner2 = threading.Thread(target=macro2.run)
runner1.start()
runner2.start()
Tips
Special Functions
import pymacro
macro = pymacro.Macro()
# Functions
macro.execute(function, times=1, interval=0, *args, **kwargs)
# End the macro early
macro.end(condition=True, wait=0)
macro()
Metadata
Release files for pymacro 0.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 | |
|---|---|---|---|
| pymacro-0.1.1.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymacro-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / pymacro-0.1.1.tar.gz
| Download URL | pymacro-0.1.1.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aad622c3839f6741f2492695311c321fcf433e35ad8db74767aca7f5840ad424
|
|
BLAKE2b-256 checksum How to use checksums |
569cad4aeaa22be00305278734eb7fdae89b39b421bd5fed002d65af95d23531
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Release files / pymacro-0.1.1-py3-none-any.whl
| Download URL | pymacro-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
450ec99f12919fc7b47f6d4ceea5064e7f227dcaa3a29d04512d0cc7d2dd3f49
|
|
BLAKE2b-256 checksum How to use checksums |
c3809c28e854bbd97f9d27836a080bb31fae1c1d7698a0f43b476d81b7ceacde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|