-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
68 lines (57 loc) · 2.31 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Imports required for this program to function
import pyautogui as pg
from pynput.keyboard import Key, Controller as kb
from pynput.mouse import Button, Controller as ms
import os
# Define mouse button constants
l = Button.left
r = Button.right
m = Button.middle
# Create keyboard and mouse controller objects
keyboard = kb()
mouse = ms()
# Get the directory path of the script
dir_path = os.path.dirname(os.path.abspath(__file__))
# Function to press enter
def enter():
kb.tap(keyboard,Key.enter)
# Function to type text using pyautogui (may be less reliable on some applications)
def write(phrases):
pg.write(phrases)
# Function to locate an image on the screen and move the mouse to its center
def locate(name, confidence):
try:
locateimage = pg.locateOnScreen(f"{dir_path}/images/{name}.png or any other image file extensions other extensions haven't been tested by me", confidence=confidence)
located = pg.center(locateimage)
pg.moveTo(located)
except:
locate(name, confidence)
# Function to click the mouse button a specified number of times (with error handling)
def click(button, amount=1):
canclickbutton = True
while canclickbutton == True:
#Clicks the mouse button a specified number of times
if not isinstance(amount, int):
print("Invalid click amount specified. Using 1 click instead.")
amount = 1
mouse.click(button, amount)
canclickbutton = False
# Press the command key (might be different on some systems)
kb.tap(keyboard,Key.cmd)
# Use pyautogui to locate an image named "checkfortaskbar" and write "Ubuntu"
locate("insert image name without .png or file extensions", .8)
write("insert what you want written")
# Use locate to find "checkforlinuxapp" and press enter
locate("insert image name without .png or file extensions", .8)
enter()
# Similar steps to locate "checkfortaskbar", click it, write "cd privateGPT", etc.
locate("insert image name without .png or file extensions", .8)
click(l)
write("insert what you want written")
locate("insert image name without .png or file extensions", .8)
enter()
# Similar steps to locate "checkforlinuxsys"
locate("insert image name without .png or file extensions", .8)
write("insert what you want written")
locate("insert image name without .png or file extensions", .8)
enter()