利用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
相关推荐
我不会起名字3224 分钟前
一天一道算法题(26):栈的简单应用
java·数据结构·python·算法·leetcode·golang·
爱吃苹果的梨叔8 分钟前
AI 算力监控中心怎么建?分布式坐席 + 大屏联动 + 过程回放
人工智能·分布式·python
JarmanYuo8 分钟前
YOLO 涨点研究(六):网络结构改进之小目标增强篇1——无人机视角下的车辆与行人检测
人工智能·pytorch·python·yolo·计算机视觉·无人机
2601_9622972513 分钟前
python自带缓存lru_cache用法及扩展的使用_python
python·缓存·装饰器·lru_cache·my_cache
招财小梗18 分钟前
沈阳AI企业咨询可定制数字化方案吗?
大数据·人工智能·python
磐链科技21 分钟前
区块链开发入门实战:用 Hardhat 与 Ethers.js 搭建你的第一个 DApp
开发语言·javascript·区块链
csdn2015_24 分钟前
java springboot项目,接收到的参数多个逗号
java·开发语言·spring boot
leihefeng34 分钟前
邮件文本分类:CountVectorizer / TF-IDF + 朴素贝叶斯
python·分类·数据挖掘·tf-idf·sklearn
码艺-Alimjan35 分钟前
维吾尔语数字转文本
java·javascript·python·算法·go