一、目的
通过按下键盘特定按键,开始运行python文件
二、code
from pykeyboard import PyKeyboardEvent
from pykeyboard import *
from pymouse import PyMouseEvent
import PyHook3
import hello
class Clickonacci(PyKeyboardEvent):
def __init__(self):
PyKeyboardEvent.__init__(self)
def tap(self, keycode, character, press):
'''Print Fibonacci numbers when the left click is pressed.'''
if character == 'z':
if press:
print ('hello2')
# python 文件
hello.hello()
else: # Exit if any other mouse button used
print(character)
C = Clickonacci()
C.run()
靠谱教程
https://blog.csdn.net/qq_38839677/article/details/83374219
主要包 pykeyboard,pymouse, pyhook3(是模拟键盘输入和鼠标点击的库,也可以读取键盘和鼠标的信息,pyhook3适应python3, 如果pyhook是适应python2的会报错)。pyhook3包含pykeyboa