|
| 1 | +# Python Auto Draw |
| 2 | +##### THIS SIMPLE PROJECT WAS MADE TO LEARN PYTHON LIBRARY FUNCTIONS LIKE `pyatogui` & `time`. |
| 3 | + |
| 4 | +### *DEMO*: |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +### To run it on your PC: |
| 11 | +* Make sure you have Python 3.7.x or Python 3.8.x installed, if not, click [here](https://www.python.org/downloads/) to install! |
| 12 | +* Install PyAutoGUI: `pip install pyautogui` |
| 13 | +* Clone this into your Desktop: `git clone "https://github.com/tusharnankani/PythonAutoDraw"` |
| 14 | +* Open Command Line or Terminal |
| 15 | +* Change directory to a respective game: `cd "Desktop\PythonAutoDraw"` |
| 16 | +* Run: `python python-auto-draw.py` |
| 17 | + |
| 18 | + |
| 19 | +### BASICS: |
| 20 | +<code> |
| 21 | +>>> import pyautogui |
| 22 | +</code> |
| 23 | + |
| 24 | + |
| 25 | +`>>> screenWidth, screenHeight = pyautogui.size()` # Get the size of the primary monitor. |
| 26 | + |
| 27 | +`>>> currentMouseX, currentMouseY = pyautogui.position()` # Get the XY position of the mouse. |
| 28 | + |
| 29 | +`>>> pyautogui.moveTo(100, 150)` # Move the mouse to XY coordinates. |
| 30 | + |
| 31 | +`>>> pyautogui.click()` # Click the mouse.<br> |
| 32 | +`>>> pyautogui.click(100, 200)` # Move the mouse to XY coordinates and click it.<br> |
| 33 | +`>>> pyautogui.click('button.png')` # Find where button.png appears on the screen and click it.<br> |
| 34 | + |
| 35 | +`>>> pyautogui.move(0, 10)` # Move mouse 10 pixels down from its current position.<br> |
| 36 | +`>>> pyautogui.doubleClick()` # Double click the mouse.<br> |
| 37 | +`>>> pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad)` # Use tweening/easing function to move mouse over 2 seconds.<br> |
| 38 | + |
| 39 | +`>>> pyautogui.write('Hello world!', interval=0.25)` # type with quarter-second pause in between each key<br> |
| 40 | +`>>> pyautogui.press('esc')` # Press the Esc key. All key names are in pyautogui.KEY_NAMES<br> |
| 41 | + |
| 42 | +`>>> pyautogui.keyDown('shift')` # Press the Shift key down and hold it.<br> |
| 43 | +`>>> pyautogui.press(['left', 'left', 'left', 'left'])` # Press the left arrow key 4 times.<br> |
| 44 | +`>>> pyautogui.keyUp('shift')` # Let go of the Shift key.<br> |
| 45 | + |
| 46 | +`>>> pyautogui.hotkey('ctrl', 'c')` # Press the Ctrl-C hotkey combination.<br> |
| 47 | + |
| 48 | +`>>> pyautogui.alert('This is the message to display.')` # Make an alert box appear and pause the program until OK is clicked.<br> |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +## *REFERENCES*: |
| 54 | +- [PyAutoGUI Docs](https://pypi.org/project/PyAutoGUI/) |
| 55 | +- [More about PyAutoGUI](https://pyautogui.readthedocs.io/en/latest/mouse.html#mouse-drags) |
0 commit comments