from pynput.keyboard import Key,Controller import time from random import choice time.sleep(5) # 创建键盘对像 keyboard_run = Controller() # 按个回车 def send(): # 按下 keyboard_run.press(Key.enter) # 释放 keyboard_run.release(Key.enter) # 输入文字 def msg(a): keyboard_run.type(a) # 输出文字 # 跑起来 if __name__ == '__main__': msg_list = ['xk','nkt','xyx','hd','gz','kb','ch','lengh','dk','xig','oh','fw','shui','shi','ws','ruo','qiang','yl','ty','bz','lw','xs','xin','dx','mg','fan','kf', 'hx','bb','zq','dao','zhd','shd','dg','ll','yb'] x = 0 while x<100: msg('/'+choice(msg_list)) # 输入 send() # 发送 x += 1 if x > 150: break print(x) # # 顺着按下,返着释放 # with keyboard_run.pressed( # Key.shift, # Key.ctrl, # ): # 按下shift # print('end') # shift + a