-
Notifications
You must be signed in to change notification settings - Fork 0
/
Screen_Module.py
40 lines (31 loc) · 1018 Bytes
/
Screen_Module.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
from PIL import ImageGrab
import msvcrt
import win32gui
class Screen_Module:
def __init__(self):
self.init = False
self.x = 0
self.y = 0
self.x1 = 0
self.y1 = 0
def get_point(self):
ret = True
while ret:
c = msvcrt.getwch()
if "c" == c:
ret = False
(tmpX,tmpY) = win32gui.GetCursorPos()
return tmpX, tmpY
def init_box_coordinate(self):
print ("Place mouse to top left of box, and press key \"c\"")
self.x, self.y = self.get_point()
print ("Place mouse to bottom right of box, and press key \"c\"")
self.x1, self.y1 = self.get_point()
print("(X,Y) = (%d, %d), (X1,Y1) = (%d, %d)" %(self.x, self.y, self.x1, self.y1))
self.init = True
def grab(self):
if (not self.init):
print("Not initalized yet")
else:
im=ImageGrab.grab(bbox=(self.x,self.y,self.x1,self.y1))
return im