|
| 1 | +# importing modules |
| 2 | +import time |
| 3 | +import pyautogui |
| 4 | +#import pyautogui |
| 5 | + |
| 6 | +# returns a point object with |
| 7 | +# x and y values |
| 8 | +print(pyautogui.position()) |
| 9 | + |
| 10 | +# returns a size object with |
| 11 | +# width and height of the screen |
| 12 | +print(pyautogui.size()) |
| 13 | + |
| 14 | +# moves to (519,1060) in 1 sec |
| 15 | +pyautogui.moveTo(519, 1060, duration = 1) |
| 16 | + |
| 17 | +# simulates a click at the present |
| 18 | +# mouse position |
| 19 | +pyautogui.click() |
| 20 | + |
| 21 | +# moves to (1717,352) in 1 sec |
| 22 | +pyautogui.moveTo(1717, 352, duration = 1) |
| 23 | + |
| 24 | +# simulates a click at the present |
| 25 | +# mouse position |
| 26 | +pyautogui.click() |
| 27 | + |
| 28 | +# moving the cursor left 498 px & down |
| 29 | +# 998px from it's current position |
| 30 | +pyautogui.moveRel(-498,996, duration = 1) |
| 31 | + |
| 32 | +# clicks at the present location |
| 33 | +pyautogui.click() |
| 34 | + |
| 35 | +# moves to the specified location |
| 36 | +pyautogui.moveTo(1165,637, duration = 1) |
| 37 | + |
| 38 | +# right clicks at the present cursor |
| 39 | +# location |
| 40 | +pyautogui.click(button="right") |
| 41 | + |
| 42 | +# moves to the specified location |
| 43 | +pyautogui.moveTo(1207,621, duration = 1) |
| 44 | + |
| 45 | +# clicks at the present location |
| 46 | +pyautogui.click() |
| 47 | + |
| 48 | +# cursor moves to a specific position |
| 49 | +pyautogui.moveTo(519,1060, duration = 1) |
| 50 | + |
| 51 | +# left clicks at the current position |
| 52 | +pyautogui.click() |
| 53 | + |
| 54 | +# cursor moves to a specific position |
| 55 | +pyautogui.moveTo(1550,352, duration = 1) |
| 56 | + |
| 57 | +# left clicks and holds and moves the |
| 58 | +# curson to (500,500) position |
| 59 | +pyautogui.dragTo(500,500, duration = 1) |
| 60 | + |
| 61 | +# drags the cursor relative to it's |
| 62 | +# position to 5opx right and 50 px down |
| 63 | +pyautogui.dragRel(50,50, duration=1) |
| 64 | + |
| 65 | + |
| 66 | +# used to access time related functions |
| 67 | +#import time |
| 68 | +#import pyautogui |
| 69 | + |
| 70 | +# pauses the execution of the program |
| 71 | +# for 5 sec |
| 72 | +time.sleep(5) |
| 73 | + |
| 74 | +# types the string passed inside the |
| 75 | +# function |
| 76 | +pyautogui.typewrite("Github") |
| 77 | + |
| 78 | +# pauses the execution of the program |
| 79 | +# for 5 sec |
| 80 | +time.sleep(5) |
| 81 | + |
| 82 | +# types the string passed inside the |
| 83 | +# function |
| 84 | +pyautogui.typewrite("Geeks For Geeks!") |
| 85 | + |
| 86 | +# simulates pressing the enter key |
| 87 | +pyautogui.press("enter") |
| 88 | + |
| 89 | +# simulates pressing the hotkey ctrl+a |
| 90 | +pyautogui.hotkey("ctrl","a") |
| 91 | + |
| 92 | +# a alert displays with a ok button |
| 93 | +# on it |
| 94 | +pyautogui.alert(text='', title='', button='OK') |
| 95 | + |
| 96 | +# a confirm dialog box appears with ok |
| 97 | +# and cancel buttons on it |
| 98 | +pyautogui.confirm(text='', title='', buttons=['OK', 'Cancel']) |
| 99 | + |
| 100 | +# a prompt displays that lets you to |
| 101 | +# write something |
| 102 | +pyautogui.prompt(text='', title='' , default='') |
| 103 | + |
| 104 | +# a password field appears with entry box |
| 105 | +# to fill a password |
| 106 | +pyautogui.password(text='', title='', default='', mask='*') |
| 107 | + |
| 108 | +# takes a screenshot of the present |
| 109 | +# window and stores it as "123.png" |
| 110 | +pyautogui.screenshot("abc.png") |
0 commit comments