-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
61 lines (58 loc) · 2.05 KB
/
script.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
import cv2
import numpy as np
import pyautogui
import time
import pytesseract
import keyboard as kbd
pytesseract.pytesseract.tesseract_cmd = r'where you have tesseract.exe path'
import cv2
import numpy as np
from pynput import mouse
screenshot = pyautogui.screenshot()
screenshot.save(f"pathtosave")
img = cv2.imread(r"thescreenshotpath aka pathtosave", 1)
click1 = False
point1 = (0,0)
def on_click(x, y, button, pressed):
print('{0} at {1}'.format(
'Pressed' if pressed else 'Released',
(x, y)))
time.sleep(1)
kbd.write(f"{chestie}", 0.01)
time.sleep(10000)
if not pressed:
# Stop listener
return False
def click(event,x,y,flags, params):
global click1, point1
if event == cv2.EVENT_LBUTTONDOWN:
# daca apesi salvezi chestii xy bbbbbbbbbbbbbbbbbbbbbbbbbbbbb
click1 = True
point1 = (x,y)
elif event == cv2.EVENT_MOUSEMOVE and click1:
#deseneaza aia rosie
img_copy = img.copy()
cv2.rectangle(img_copy, point1, (x,y), (0,0,255),2)
cv2.imshow("Image", img_copy)
elif event == cv2.EVENT_LBUTTONUP:
#face poza
click1 = False
sub_img = img[point1[1]:y,point1[0]:x]
cv2.imshow("subimg", sub_img)
cv2.imwrite('final.jpg', sub_img)
imgggggggggg = cv2.imread('final.jpg')
bruuhhhhhhhhhhhhhhhhhhhhh = str(pytesseract.image_to_string(imgggggggggg))
print(bruuhhhhhhhhhhhhhhhhhhhhh)
global chestie
chestie = bruuhhhhhhhhhhhhhhhhhhhhh.replace('\n', ' ')
time.sleep(2)
print("time done")
with mouse.Listener(
on_click=on_click
) as listener:
listener.join()
cv2.namedWindow("Image")
cv2.setMouseCallback("Image", click)
cv2.imshow("Image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()