{
"info": {
"author": "UNKNOWN",
"author_email": "UNKNOWN",
"bugtrack_url": null,
"classifiers": [],
"description": "pyrobot\n=======\n\n\nWhat is it?\n----------- \n\nPyRobot is a lightweight, pure Python Windows automation library loosely modeled after Java's Robot Class. It can be used to drive applications that don't provide an API or any way of hooking into them programatically. Good for when you can't (or don't want to) install the great, but a bit hefty, pywin32 libraries. \n\nYou can check out a couple of use cases for PyRobot [here](https://medium.com/p/697d2c968a2f)\n\nInstallation\n------------\n\nPyRobot is a single Python file. So, you can either download it directly from this github page, or clone the repo: \n\ngit clone https://github.com/chriskiehl/pyrobot \n\nUsage\n------\n\nSimilar to Java, everything is controlled via a single class.\n\n ```python\n\n# Import the robot class from the pyrobot module\nfrom pyrobot import Robot\n\n# create an instance of the class\nrobot = Robot()\n\n# Launch a program\nrobot.start_program('program_name') \n\n# Do cool stuff\nlocation_of_field = (340, 400)\nexpected_color = (255,255,255)\n\npixel = robot.get_pixel(location_of_field)\nif pixel == (expected_color): \n\trobot.set_mouse_pos(location_of_field)\n\trobot.click_mouse(button='left')\n\trobot.add_to_clipboard('Hello world! How are ya!')\n\trobot.paste()\n\n\n# etc.. \n\n# If you need to take screengrabs, and have PIL Installed, \n# PyRobot extends the default behavior of PIL by \n# allowing the entire virtual screen to be targeted (rather \n# than just the primary). \n\n# returns a list of screen rects for all attached devices\nmonitors_coords = robot.get_display_monitors() \n\n# Takes a screenshot of the desktop and returns a PIL Image object\nim = robot.take_screenshot(monitors_coords[-1]) # Coordinates of last monitor\n\n# You can also do arbitrarily sized boxes\nleft = 100\ntop = 430\nwidth = 1000\nhright = 750\n\nim = robot.take_screenshot((left, top, width, height))\n\n# Save the PIL Image to disk\nim.save('my_awesome_screenshot.png', 'png')\n\n# and so on\n ``` \n\nUpdates\n------- \n\n* Added ability to read data from the clipboard. \n\n my_var = robot.get_clipboard_data()\n\n* convenience method `press_and_release` \n \n robot.press_and_release('caps_lock')\n\n* Added `Key` class\n \n from pyrobot import Robot, Keys\n robot = Robot() \n \n robot.press_and_release(Keys.forward_slash)\n\n\n\n\nDoc \n--- \n\n\n####Mouse\n\n| Method | Summary |\n| --------------------------- | --------------------------- |\n| get_mouse_pos() | Returns tuple of current mouse coordinates |\n| set_mouse_pos(x, y) | Moves mouse pointer to given screen coordinates. |\n| click_mouse(button) | Simulates a full mouse click. One down event, one up event.
button can be `'Left'`, `'right'`, or `'middle'` |\n| double_click_mouse(button) | Two full mouse clicks. One down event, one up event. |\n| move_and_click(x,y,button) | convenience function: Move to coordinates and click mouse |\n| mouse_down(button) | Presses one mouse button.
button can be `'Left'`, `'right'`, or `'middle'` |\n| mouse_up(button) | Releases mouse button.
button can be `'Left'`, `'right'`, or `'middle'` |\n| scroll_mouse_wheel(direction, clicks) | Scrolls the mouse wheel either `'up'` or `'down'` X number of 'clicks'. |\n\n\n####Keys\n\n| Method | Summary |\n| --------------------------- | --------------------------- |\n| key_press(key) | Presses a given key.
Input: `string` or `Keys.*` constant |\n| key_release(key) | Releases a given key.
Input: `string` or `Keys.*` constant |\n| press_and_release() | Simulates pressing a key: One down event, one release event | \n\n\n####Clipboard\n\n| Method | Summary |\n| --------------------------- | --------------------------- |\n| add_to_clipboard(string) | Copy text into clip board for later pasting. |\n| clear_clipboard() | Clear everything out of the clipboard |\n| get_clipboard_data() | Retrieves text from the Windows clipboard as a String |\n| paste() | Pastes the contents of the clipboard |\n\n\n####Screen\n\n| Method | Summary |\n| --------------------------- | --------------------------- |\n| get_display_monitors() | Enumerates and returns a list of virtual screen coordinates for the attached display devices
output = [
(left, top, right, bottom), # Monitor 1
(left, top, right, bottom) # Monitor 2
# etc...
] |\n| get_pixel(x, y) | Returns the pixel color `tuple(R,G,B)` of the given screen coordinate |\n| take_screenshot(bounds=None) | NOTE: REQUIRES PYTHON IMAGE LIBRARY
Takes a screenshot of the entire desktop and returns it as a PIL `Image` object.
Use with `get_display_monitors` to target a specific screen, or pass in a tuple consisting of (`left`, `top`, `width`, `height`). |\n\n\n####Misc\n\n| Method | Summary |\n| --------------------------- | --------------------------- |\n| sleep(duration) | Pauses the robot for `duration` number of seconds. |\n| start_program(full_path) | Launches a windows application.
Input type: `string` |\n| type_backwards(input_string, delay=.05) | Types right to left. Because why not! |\n| type_string(input_string, delay=.005) | Convenience function for typing out strings.
delay = time between keystrokes |\n\n\n\n\nSpecial take_snapshot Note\n----------------------- \n\nBeing that Python has no built in Image library (that I know of), it seemed of little use to include a snapshot method which simply saves the picture to disk. For 90% of program automation, I find that querying pixels works fairly well (e.g. `robot.get_pixel`). However, if you need to do more advanced display searching, or want to do template matching, you'll need an external library. So there is a method in there to contruct a PIL Image object. It just, of course, requires that PIL be installed. Other than that, dependency free! :-) \n\nTODO\n---- \n\n* Allow specific window/program targeting so that relative coordinates can be used while scripting. \n\n\nContact\n-------\n\nFeature request? Bug? Hate it? \nDrop me a line at audionautic@gmail.com, or on Twitter @thechriskiehl",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "UNKNOWN",
"keywords": null,
"license": "The MIT License (MIT)",
"maintainer": null,
"maintainer_email": null,
"name": "py_robot",
"package_url": "https://pypi.org/project/py_robot/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/py_robot/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "UNKNOWN"
},
"release_url": "https://pypi.org/project/py_robot/0.1/",
"requires_dist": null,
"requires_python": null,
"summary": "UNKNOWN",
"version": "0.1"
},
"last_serial": 1199945,
"releases": {
"0.1": []
},
"urls": []
}