Skip to content

Commit

Permalink
修注释
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroi-sora committed Apr 22, 2023
1 parent 0d1d803 commit a146dc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 96 deletions.
5 changes: 3 additions & 2 deletions ui/win_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def startGrab(self): # 启动截屏
scRight = s[2]
if s[3] > scDown: # 下边缘
scDown = s[3]
# 计算虚拟屏幕的宽和高
# 计算虚拟屏幕的宽和高,请确保屏幕对齐
scWidth, scHeight = scRight - scLeft, scDown - scUp
# 多显示器处理完毕
self.scBoxVirtual = (scLeft, scUp, scRight, scDown,
Expand Down Expand Up @@ -348,7 +348,7 @@ def __createGrabImg(self): # 创建剪切图像
box[1], box[3] = box[3], box[1]
for i in range(4):
box[i] *= self.allScale # 乘上缩放比例
self.imageResult = self.image.crop(box)
self.imageResult = self.image.crop(box) # 裁切,产生最终截图数据

def __onClose(self, event=None): # 关闭窗口
if not self.isInitGrab:
Expand All @@ -375,6 +375,7 @@ def closeFlash(): # 关闭闪光
for i in self.flashList:
self.canvas.delete(i)
self.flashList = []

for box in self.scBoxList:
p1x, p1y, p2x, p2y = box
p1x -= self.scBoxVirtual[0]
Expand Down
94 changes: 0 additions & 94 deletions utils/hotkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,97 +67,3 @@ def removeMouse():
def getMousePos():
'''获取鼠标当前位置'''
return hotkeyApi.getMousePos()


"""
# 旧版热键类。依赖 keyboard 库,这个库年久失修Bug多,弃之。
# 顺带 mouse 也遗弃,pynput已经包含鼠标监听的接口。
import keyboard # 绑定快捷键
import mouse # 绑定鼠标键
class Hotkey():
@staticmethod
def add(hotkey, callback):
'''添加一个快捷键组合监听。按下时调用callback'''
# suppress=False 允许按键事件继续向别的软件下发,否则系统中相同辅助键的快捷键全都失效
keyboard.add_hotkey(hotkey, callback, suppress=False)
Log.info(f'注册按键按下【{hotkey}】')
@staticmethod
def addRelease(hotkey, callback):
'''添加一个快捷键组合监听。松开时调用callback'''
keyboard.on_release_key(hotkey, callback, suppress=False)
Log.info(f'注册按键抬起【{hotkey}】')
@staticmethod
def remove(hotkey):
'''移除一个快捷键组合监听'''
keyboard.remove_hotkey(hotkey) # 移除该快捷键
Log.info(f'注销按键监听【{hotkey}】')
@staticmethod
def read(callback):
'''录制快捷键。按下并松开一组按键,将按键序列字符串发送到回调函数\n
成功:返回hotkey字符串\n
失败:hotkey为空,errmsg为错误字符串'''
try:
hotkey = keyboard.read_hotkey(suppress=False)
Log.info(f'录制按键组合【{hotkey}】')
callback(hotkey)
except ValueError as err:
callback('', err)
@staticmethod
def isPressed(hotkey):
'''检查当前是否按下hotkey序列,是返回T'''
return keyboard.is_pressed(hotkey)
@staticmethod
def send(hotkey):
'''发送按键序列'''
keyboard.send(hotkey)
Log.info(f'发送按键组合【{hotkey}】')
# ========================== 鼠标1 ==============================
@staticmethod
def addMouseButtonDown(callback):
'''添加一个鼠标按钮监听。按下时调用callback,返回xy坐标元组'''
def cb():
pos = mouse.get_position() # 获取鼠标当前位置
callback(pos)
mouse.on_button(cb,
buttons=('left', 'right'), types='down')
@staticmethod
def addMouseButtonUp(callback):
'''添加一个鼠标按钮监听。松开时调用callback,返回xy坐标元组'''
def cb():
pos = mouse.get_position() # 获取鼠标当前位置
callback(pos)
mouse.on_button(cb,
buttons=('left', 'right'), types='up')
@staticmethod
def removeMouse():
'''移除鼠标监听'''
mouse.unhook_all()
# ========================== 鼠标2 ==============================
@staticmethod
def addMouseButtonDown(callback):
'''添加一个鼠标按钮监听。按下时调用callback,返回xy坐标元组'''
hotkeyApi.addMouseButtonDown(callback)
@staticmethod
def addMouseButtonUp(callback):
'''添加一个鼠标按钮监听。松开时调用callback,返回xy坐标元组'''
hotkeyApi.addMouseButtonUp(callback)
@staticmethod
def removeMouse():
'''移除鼠标监听'''
hotkeyApi.removeMouse()
"""

0 comments on commit a146dc7

Please sign in to comment.