Skip to content

Commit d04373b

Browse files
committed
Made desktop automation scripts using pyautogui for controlling mouse,keyboard and screenshot
1 parent 99df5f7 commit d04373b

File tree

1 file changed

+26
-0
lines changed
  • Automation/src/desktop_automation_scripts/automation of mouse and keyboard using python

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pyautogui
2+
3+
width, height = pyautogui.size() # set width and height to your screen pixels.
4+
print(pyautogui.position()) # get mouse position
5+
pyautogui.click(
6+
100, 100, button="left"
7+
) # click left mouse at (100,100) similarly use .mouseUp(),.mouseDown(),.doubleClick() etc
8+
pyautogui.scroll(400) # scroll down 400
9+
pyautogui.moveTo(
10+
500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad
11+
) # Use tweening/easing function to move mouse over 2 seconds.
12+
pyautogui.write(
13+
"Hello world!", interval=0.25
14+
) # Type with quarter-second pause in between each key.
15+
pyautogui.press("esc") # Simulate pressing the Escape key.
16+
pyautogui.keyDown("shift")
17+
pyautogui.write(["left", "left", "left", "left", "left", "left"])
18+
pyautogui.keyUp("shift")
19+
pyautogui.hotkey("ctrl", "c") # pressed in succession like ctrl+c
20+
21+
# For taking Screenshot
22+
im1 = pyautogui.screenshot()
23+
im1.save("my_screenshot.png")
24+
im2 = pyautogui.screenshot("my_screenshot2.png")
25+
# locating image on screen
26+

0 commit comments

Comments
 (0)