利用python进行键盘模拟输入

利用python进行键盘模拟输入
python打包分发工具:setuptools

python 复制代码
#用于键盘英文字符输入模拟
import pyautogui
import time


def simulate_typing(text):
    # Give some time to switch to the desired application
    time.sleep(5)

    # Simulate typing each character
    for char in text:
        pyautogui.typewrite(char)
        time.sleep(0.1)  # Adjust the delay between keystrokes if needed

    # Press Enter key at the end
    pyautogui.press('enter')


# 要输入的英文字符
input_text = input("Enter the text : ")
simulate_typing(input_text)
python 复制代码
#用于键盘中文字符输入模拟
from pynput.keyboard import Controller
import time


def type_chinese_text(text):
    keyboard = Controller()
    time.sleep(5)
    for char in text:
        keyboard.type(char)
        time.sleep(0.1)  # Adjust the delay between keystrokes if needed


# 要输入的中文字符
input_text = input("Enter the text : ")

type_chinese_text(input_text)

遇到回车键也能持续输入

https://www.cnblogs.com/programmer4027/p/14687119.html

python中iter方法_深入了解Python iter() 方法的用法

https://blog.csdn.net/weixin_39559804/article/details/110830564

问题:图标不显示

https://www.ico51.cn/

打包后可能会出现程序图标未生效的情况,原因可能有如下:

1、未使用ico文件作为图标文件

2、准备好的ico文件无效,可能是通过直接修改后缀名的图片文件。

处理办法:

下载ico文件作为图标,或者利用专门的转换工具将png、jpeg等图片文件转换成ico文件。比如格式工厂之类的。

python 复制代码
pyinstaller  -y -F -n demo_max -i D:\favicon_max.ico .\main.py
相关推荐
数新网络2 分钟前
PyTorch
人工智能·pytorch·python
自信的小螺丝钉6 分钟前
【大模型手撕】pytorch实现LayerNorm, RMSNorm
人工智能·pytorch·python·归一化·rmsnorm·layernorm
深耕AI6 分钟前
PyTorch图像预处理:ToTensor()与Normalize()的本质区别
人工智能·pytorch·python
落日沉溺于海8 分钟前
React From表单使用Formik和yup进行校验
开发语言·前端·javascript
鲸屿1951 小时前
python之socket网络编程
开发语言·网络·python
里昆1 小时前
【AI】Tensorflow在jupyterlab中运行要注意的问题
人工智能·python·tensorflow
AI视觉网奇1 小时前
pycharm 最新版上一次编辑位置
python
没有梦想的咸鱼185-1037-16631 小时前
基于R语言机器学习方法在生态经济学领域中的实践技术应用
开发语言·机器学习·数据分析·r语言
2401_828890641 小时前
使用 BERT 实现意图理解和实体识别
人工智能·python·自然语言处理·bert·transformer
向上的车轮2 小时前
基于go语言的云原生TodoList Demo 项目,验证云原生核心特性
开发语言·云原生·golang