Skip to content

Commit caa1454

Browse files
authored
Merge pull request Python-World#183 from tusharnankani/auto-draw
Add Python Auto Draw to projects.
2 parents daa8c74 + 738e6d1 commit caa1454

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Python Auto Draw
2+
##### THIS SIMPLE PROJECT WAS MADE TO LEARN PYTHON LIBRARY FUNCTIONS LIKE `pyatogui` & `time`.
3+
4+
### *DEMO*:
5+
6+
![Demo](pyautoguidemo.gif)
7+
![1](https://user-images.githubusercontent.com/61280281/89520553-a5676000-d7fb-11ea-8e2f-883782ddcbc6.png)
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)
114 KB
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pyautogui
2+
import time
3+
4+
# time to change tabs from editor to paint;
5+
time.sleep(10)
6+
7+
# it will remain clicked till program ends;
8+
pyautogui.click()
9+
10+
# can be varied according to convininence
11+
distance = 250
12+
13+
while distance > 0:
14+
# right
15+
pyautogui.dragRel(distance, 0, duration = 0.1)
16+
17+
distance -= 5
18+
19+
# down
20+
pyautogui.dragRel(0, distance, duration = 0.1)
21+
22+
# left
23+
pyautogui.dragRel(-distance, 0, duration = 0.1)
24+
25+
distance -= 5
26+
27+
#up
28+
pyautogui.dragRel(0, -distance, duration = 0.1)
29+

0 commit comments

Comments
 (0)