-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·70 lines (61 loc) · 1.77 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
69
70
import keyboard
import pyautogui
import time
import os
import mouse
from PIL import Image, ImageGrab
import pytesseract
import numpy as np
import sys
import subprocess
pages = int(input("Enter the number of pages in the document: "))
os.system("notify-send \"Put your cursor at the top left of your document\" -t 6000")
time.sleep(1)
count = 5
while count != 0:
os.system(f"notify-send \"{count}\"... -t 1000")
count -= 1
time.sleep(1)
top_left = mouse.get_position()
os.system("notify-send \"Put your cursor at the bottom right of your document\" -t 6000")
time.sleep(1)
count = 5
while count != 0:
os.system(f"notify-send \"{count}...\" -t 1000")
count -= 1
time.sleep(1)
bottom_right = mouse.get_position()
# time.sleep(2)
# os.system("notify-send \"Put your cursor at the copy icon\" -t 6000")
# time.sleep(1)
# count = 5
# while count != 0:
# os.system(f"notify-send \"{count}...\" -t 1000")
# count -= 1
# time.sleep(1)
# copy_icon_pos = mouse.get_position()
# pyautogui.moveTo(copy_icon_pos)
# time.sleep(.2)
# pyautogui.leftClick()
for i in range(pages):
time.sleep(0.5)
# for flameshot applet
# pyautogui.moveTo(1910,10)
# pyautogui.leftClick()
# time.sleep(0.1)
subprocess.Popen(["flameshot", "gui"])
pyautogui.moveTo(top_left)
time.sleep(0.1)
pyautogui.dragTo(bottom_right, duration=.5)
pyautogui.hotkey("ctrl", "c")
# pyautogui.moveTo(copy_icon_pos)
time.sleep(.2)
pyautogui.leftClick()
pyautogui.press("j")
ImageGrab.grabclipboard().save('/home/adi/Pictures/text.png','PNG')
filename = '/home/adi/Pictures/text.png'
img1 = np.array(Image.open(filename))
text = pytesseract.image_to_string(img1)
with open(sys.argv[1], "a") as f:
f.write(text)
f.write("\n")