-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunc.py
103 lines (80 loc) · 2.65 KB
/
func.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import re
import pyautogui
import pygetwindow as gw
from pynput import mouse
from win32 import win32api
import config as conf
# get分辨率
screenX = win32api.GetSystemMetrics(0)
screenY = win32api.GetSystemMetrics(1)
# 缩放比率
scale_rate = conf.dpi_dict[conf.read_conf('General', 'DPI')]
ppt_window_title = conf.read_conf('General', 'PPT_Title')
tsk_edge = screenY - 95 * scale_rate
ppt_menuWL = 95 * scale_rate
ppt_menuWR = screenX - 95 * scale_rate
is_pressed = False
pressed_menuButton = False
pos_mouse = [0, 0]
count = 0
# 检测是否有PowerPoint放映
def is_powerpoint_showing():
try:
if bool(conf.read_conf('General', 'use_regex')):
windows = gw.getWindowsWithTitle(ppt_window_title)
return len(windows) > 0
else:
windows = gw.getAllTitles()
for window in windows:
if re.search(conf.read_conf('General', 'DPI'), window):
return True
except Exception:
print(f'这是\n{Exception}\n喵') # QwQ
return False
def is_finger_not_slide(x, y):
if [x, y] == pos_mouse:
return True
else:
return False
def is_not_click_taskbar(mouse_y):
if mouse_y <= tsk_edge:
return True
else:
return False
def is_not_click_ppt_menubar(mouse_x):
if ppt_menuWL <= mouse_x <= ppt_menuWR:
return True
else:
return False
# 点击事件
def on_click(x, y, button, pressed):
global is_pressed
global pos_mouse
global pressed_menuButton
global count
if button == mouse.Button.right:
pressed_menuButton = True
if button == mouse.Button.left:
if pressed:
pos_mouse = [x, y]
if is_not_click_ppt_menubar(x) is False or is_not_click_taskbar(y) is False:
pressed_menuButton = True
count = 2
else:
is_pressed = True
# ##如果点击ppt工具栏,禁用下一次左键点击以操作弹出的菜单###
else: # 当放开时判定是否按下且符合条件
if is_pressed and pressed_menuButton is False and is_finger_not_slide(x, y) and is_powerpoint_showing():
pyautogui.press('space')
elif count != 0:
count -= 1
if count == 0:
pressed_menuButton = False
is_pressed = False
# 监听
def main():
print('程序运行中……\nRinLit_233OuO @bilibili')
with mouse.Listener(on_click=on_click) as listener:
listener.join()
if __name__ == '__main__':
main()