利用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
相关推荐
XL's妃妃6 小时前
Java 基准测试工具 JMH 详细介绍
java·开发语言·测试工具
serve the people6 小时前
PQ+IVF组合解决海量向量内存占用高和检索慢的问题
人工智能·python
on_pluto_6 小时前
【debug】解决 5070ti 与 pytorch 版本不兼容的问题
人工智能·pytorch·python
嫂子的姐夫6 小时前
02-多线程
爬虫·python·多线程·并发爬虫·基础爬虫
free-elcmacom6 小时前
MATLAB信号分析:眼图生成与高速系统评估
开发语言·matlab·信号处理
多则惑少则明6 小时前
【算法题4】找出字符串中的最长回文子串(Java版)
java·开发语言·数据结构·算法
【建模先锋】6 小时前
基于Python的智能故障诊断系统 | SmartDiag AI (基础版)V1.0 正式发布!
开发语言·人工智能·python·故障诊断·智能分析平台·大数据分析平台·智能故障诊断系统
T.O.P_KING6 小时前
Common Go Mistakes(IV 字符串)
开发语言·后端·golang
AIsdhuang6 小时前
2025 年企业 AI 培训精选指南:聚焦企业培训场景
人工智能·python