-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathTimeIt.py
More file actions
86 lines (61 loc) · 1.6 KB
/
TimeIt.py
File metadata and controls
86 lines (61 loc) · 1.6 KB
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
84
85
86
import time
def time_it(func):
def wrap(*args, **kwargs):
time_flag = time.perf_counter()
result = func(*args)
print(func.__name__ + ': %.5fs' % (time.perf_counter() - time_flag))
return result
return wrap
from io import BytesIO
from ImgTools import *
from pymouse import PyMouse
from PIL import Image
import pyscreenshot as ImageGrab
import subprocess
import os
@time_it
def get_screenshot_adb_1():
process = subprocess.Popen('adb shell screencap -p', shell=True, stdout=subprocess.PIPE)
screenshot = process.stdout.read()
imgFile = BytesIO(screenshot)
img = Image.open(imgFile)
@time_it
def get_screenshot_adb_2():
os.system('adb exec-out screencap -p > screenshot.png')
img = Image.open('screenshot.png')
@time_it
def simulate_click_adb():
os.system('adb shell input tap 300 1500')
@time_it
def get_screenshot_linux_1():
'''
不支持预选定area
'''
im = ImageGrab.grab()
@time_it
def get_screenshot_linux_2():
os.system('import -window root -crop 300x180+100+300 screenshot.png')
src = Image.open('screenshot.png')
return src
@time_it
def get_screenshot_linux_3():
'''
不支持预选定area
'''
os.system('scrot screenshot.png')
@time_it
def get_screenshot_linux_4():
'''
不支持预选定area
'''
os.system('gnome-screenshot -f screenshot.png')
@time_it
def simulate_click_pc():
m = PyMouse()
m.click(150, 650, 1)
@time_it
def get_screenshot_windows():
from PIL import ImageGrab
img = ImageGrab.grab([100, 100, 400, 400])
if __name__ == '__main__':
pass