-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreen_shot_app.py
More file actions
39 lines (28 loc) · 984 Bytes
/
Screen_shot_app.py
File metadata and controls
39 lines (28 loc) · 984 Bytes
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
import numpy as np
import cv2
import pyautogui as pag
import datetime, os
class SSApp:
def __init__(self):
self.mainController = pag.screenshot()
self.outputFolder = "./ScreenShots"
isExist = os.path.exists(self.outputFolder)
if not isExist:
os.mkdir(self.outputFolder)
def _takeScreenShot(self):
try:
self.GetImg = cv2.cvtColor(np.array(self.mainController), cv2.COLOR_RGB2BGR)
getTime = datetime.datetime.now().strftime("%I_%M_%S_%p")
fileName = str(self.outputFolder)+"/Screen_Shot_"+str(getTime)+".png"
cv2.imwrite(fileName, self.GetImg)
return fileName
except:
return False
def runModule(self):
action = self._takeScreenShot()
if action != False:
print(action)
else:
print("Error found.")
classObj = SSApp()
classObj.runModule()