-
Notifications
You must be signed in to change notification settings - Fork 0
/
pruebaWindows.py
83 lines (65 loc) · 2.25 KB
/
pruebaWindows.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
71
72
73
74
75
76
77
78
79
80
81
82
83
from pynput import mouse
from PIL import Image
from pynput.mouse import Button
import pyscreenshot as ImageGrab
def on_move(x, y):
print('Pointer moved to {0}'.format(
(x, y)))
def on_click(x, y, button, pressed):
button = str(button)
if pressed:
if button == 'Button.left':
print('Mousebutton_left {0} at {1} Pressed'.format(x,y))
if button == 'Button.right':
print('Mousebutton_right {0} at {1} Pressed'.format(x,y))
if button == 'Button.middle':
print('Mousebutton_middle {0} at {1} Pressed'.format(x,y))
else:
if button == 'Button.left':
print('Mousebutton_left {0} at {1} Release'.format(x,y))
if button == 'Button.right':
print('Mousebutton_right {0} at {1} Release'.format(x,y))
if button == 'Button.middle':
print('Mousebutton_middle {0} at {1} Release'. format(x,y))
def on_scroll( x, y, dx, dy):
if dy < 0:
print('Scrolled {0} at {1} down'.format(x, y))
else:
print('Scrolled {0} at {1} up'.format(x, y))
print "Primer imagen.............."
# size is width/height
img = Image.open('./imagenes/office.png')
left = 2407
top = 804
width = 300
height = 200
box = (left, top, left+width, top+height)
area = img.crop(box)
area.save('cropped_0_388_image1', 'jpeg')
print "Hice la primera imagen"
def crop_image(input_image, output_image, start_x, start_y, width, height):
"""Pass input name image, output name image, x coordinate to start croping, y coordinate to start croping, width to crop, height to crop """
box = (start_x, start_y, start_x + width, start_y + height)
output_img = img.crop(box)
output_img.save(output_image +".png")
print "segunda imagen"
crop_image(img,"output", 0, 0, 1280, 399)
print "termine segunda imagen"
print "tercera imagen"
# fullscreen
im=ImageGrab.grab()
im.show()
# part of the screen
im=ImageGrab.grab(bbox=(10,10,500,500))
im.show()
im.save('cropped_image1', 'jpeg')
print "fin tercera imagen"
# to file
#ImageGrab.grab_to_file('im.png')
print "mouse monitoring............................"
# Collect events until released
with mouse.Listener(
on_move=on_move,
on_click=on_click,
on_scroll=on_scroll) as listener:
listener.join()