1 Star 0 Fork 2

wtf10029/yolov5FPS

forked from AaTZY/yolov5FPS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
logitech.py 2.63 KB
一键复制 编辑 原始数据 按行查看 历史
AaTZY 提交于 2023-12-06 23:04 . 6
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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gusuling/yolov5-fps.git
git@gitee.com:gusuling/yolov5-fps.git
gusuling
yolov5-fps
yolov5FPS
master

搜索帮助