前言
本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,如有问题请及时联系我们以作处理。
基本开发环境
- Python 3.6
- Pycharm
完整代码
1 from pynput.mouse import Button, Controller as mouse_Controller
2 from pynput.keyboard import Key, Controller as key_Controller
3 import time
4 import random
5
6 f = open(\'短句.txt\', encoding=\'utf-8\')
7 txt = f.read()
8 lis_text = txt.split(\'\\n\')
9 time.sleep(3)
10
11 mouse = mouse_Controller() # 控制鼠标
12 keyboard = key_Controller()
13 mouse.press(Button.left) # 按住鼠标左键
14 mouse.release(Button.left) # 松开鼠标左键
15 for i in range(99):
16 key_world = random.choice(lis_text)
17 time.sleep(1)
18 keyboard.type(key_world)
19 keyboard.press(Key.enter)
20 keyboard.release(Key.enter)
来源:https://www.cnblogs.com/hahaa/p/15040051.html
图文来源于网络,如有侵权请联系删除。