代码拉取完成,页面将自动刷新
同步操作将从 AaTZY/yolov5FPS 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import ctypes
import os
import pynput
import winsound
try:
root = os.path.abspath(os.path.dirname(__file__))
driver = ctypes.CDLL(f'{root}/logitech.driver.dll')
ok = driver.device_open() == 1 # 该驱动每个进程可打开一个实例
if not ok:
print('Error, GHUB or LGS driver not found')
except FileNotFoundError:
print(f'Error, DLL file not found')
class Logitech:
class mouse:
"""
code: 1:左键, 2:中键, 3:右键
"""
@staticmethod
def press(code):
if not ok:
return
driver.mouse_down(code)
@staticmethod
def release(code):
if not ok:
return
driver.mouse_up(code)
@staticmethod
def click(code):
if not ok:
return
driver.mouse_down(code)
driver.mouse_up(code)
@staticmethod
def scroll(a):
"""
a:没搞明白
"""
if not ok:
return
driver.scroll(a)
@staticmethod
def move(x, y):
"""
相对移动, 绝对移动需配合 pywin32 的 win32gui 中的 GetCursorPos 计算位置
pip install pywin32 -i https://pypi.tuna.tsinghua.edu.cn/simple
x: 水平移动的方向和距离, 正数向右, 负数向左
y: 垂直移动的方向和距离
"""
if not ok:
return
if x == 0 and y == 0:
return
driver.moveR(x, y, True)
class keyboard:
"""
键盘按键函数中,传入的参数采用的是键盘按键对应的键码
code: 'a'-'z':A键-Z键, '0'-'9':0-9, 其他的没猜出来
"""
@staticmethod
def press(code):
if not ok:
return
driver.key_down(code)
@staticmethod
def release(code):
if not ok:
return
driver.key_up(code)
@staticmethod
def click(code):
if not ok:
return
driver.key_down(code)
driver.key_up(code)
# if __name__ == '__main__': # 测试
# winsound.Beep(800, 200)
# def release(key):
# if key == pynput.keyboard.Key.end: # 结束程序 End 键
# winsound.Beep(400, 200)
# return False
# elif key == pynput.keyboard.Key.home: # 移动鼠标 Home 键
# winsound.Beep(600, 200)
# Logitech.mouse.move(100, 100)
# with pynput.keyboard.Listener(on_release=release) as k:
# k.join()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。