{"id":15010044,"url":"https://github.com/jay3332/pymacro","last_synced_at":"2025-04-09T17:53:50.078Z","repository":{"id":62581563,"uuid":"354396533","full_name":"jay3332/PyMacro","owner":"jay3332","description":"PyMacro can automate your tasks inside of Python.","archived":false,"fork":false,"pushed_at":"2021-04-04T18:46:26.000Z","size":6,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T20:01:35.491Z","etag":null,"topics":["macro","oop","py","python","tasks"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jay3332.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-03T21:19:07.000Z","updated_at":"2023-11-15T03:27:40.000Z","dependencies_parsed_at":"2022-11-03T21:30:20.066Z","dependency_job_id":null,"html_url":"https://github.com/jay3332/PyMacro","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay3332%2FPyMacro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay3332%2FPyMacro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay3332%2FPyMacro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay3332%2FPyMacro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jay3332","download_url":"https://codeload.github.com/jay3332/PyMacro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248083548,"owners_count":21045121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["macro","oop","py","python","tasks"],"created_at":"2024-09-24T19:29:40.460Z","updated_at":"2025-04-09T17:53:50.054Z","avatar_url":"https://github.com/jay3332.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pymacro\n[![Image](https://img.shields.io/pypi/v/pymacro)](https://pypi.org/project/pymacro/)\n\nPyMacro is a partial wrapper around [pyautogui](https://pypi.org/project/PyAutoGUI/). PyMacro can automate your tasks all inside of Python - give it a try!\n## Features\n- Object oriented\n- Extra utility functions\n- Asynchronous support \n## Installation\nPyMacro can be easily downloaded with PIP:\n```\npip install pymacro\n```\nYou can install the latest version from this repository, too:\n```\npip install git+https://github.com/jay3332/PyMacro\n```\n## Example Usage\n### Basic Usage\n```py\nfrom pymacro import Macro\n\nmacro = Macro()\nmacro.type(\"Hello, world!\", interval=.15)\n\nmacro(wait=2)\n```\n### Mouse/keyboard Macros\n```py\nfrom pymacro import Macro\n\nmacro = Macro()\nmacro.move_mouse_relative((0, 50), seconds=0.5)\nmacro.click()\nmacro.key_press(\"enter\")\n\nmacro(wait=0.5)\n```\n### Repeat Macro Indefinitely\n```py \nfrom pymacro import Macro\n\nmacro = Macro()\nmacro.click()\n\nmacro(wait=0.5, repeat=0, delay=0.1)\n\n# Wait 0.5 seconds before starting the macro.\n# Repeating 0 times tells pymacro to repeat this macro forever without end.\n# Delay of 0.1 means to wait 0.1 seconds between every iteration of the loop.\n```\n### Async Usage\n```py\nimport asyncio\nfrom pymacro import Macro\n\nmacro = Macro()\nmacro.type(\"Hello, world!\", interval=.15)\n\nasync def run_macro():\n    await macro.async_run(wait=2)\n\nasyncio.run(run_macro())\n```\n### Executing Functions\n```py\nfrom pymacro import Macro\n\ndef fn():\n    print(\"This function is running.\")\n\nmacro = Macro()\nmacro.execute(fn, times=5)  # execute this function 5 times \n\nmacro()\n```\n## Multi-tasking\nBecause PyMacro has asynchrounous support, it is possible to run two macros at once in the same program.\n### Multiple Macros at once (asyncio)\n```py\nimport pymacro\nimport asyncio\n\nmacro1 = pymacro.Macro()\nmacro2 = pymacro.Macro()\n\ndef print_one_to_ten():\n    for i in range(1, 11):\n        print(i)\n\nmacro1.execute(print_one_to_ten)\nmacro2.execute(print_one_to_ten)\n\nloop = asyncio.get_event_loop()\nloop.create_task(macro1.async_run())\nloop.create_task(macro2.async_run())\n```\n### Multiple Macros at once (threading)\n⚠ This is not recommended - use asyncio if possible.\n```py \nimport pymacro\nimport threading\n\nmacro1 = pymacro.Macro()\nmacro2 = pymacro.Macro()\n\ndef print_one_to_ten():\n    for i in range(1, 11):\n        print(i)\n\nmacro1.execute(print_one_to_ten)\nmacro2.execute(print_one_to_ten)\n\nrunner1 = threading.Thread(target=macro1.run)\nrunner2 = threading.Thread(target=macro2.run)\n\nrunner1.start()\nrunner2.start()\n```\n## Tips\n### Special Functions\n```py\nimport pymacro\nmacro = pymacro.Macro()\n\n# Functions\nmacro.execute(function, times=1, interval=0, *args, **kwargs)\n\n# End the macro early \nmacro.end(condition=True, wait=0)\n\nmacro()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay3332%2Fpymacro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjay3332%2Fpymacro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay3332%2Fpymacro/lists"}