利用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
相关推荐
三道渊25 分钟前
C语言:文件I/O
c语言·开发语言·数据结构·c++
hnlgzb28 分钟前
安卓app kotlin语法,Hilt是什么东西?
android·开发语言·kotlin
没用的阿_吉35 分钟前
windows10 Qt5.15.14 msvc2019 编译部署
开发语言·qt
聊聊MES那点事37 分钟前
JavaScript图表控件AG Charts使用教程:使用AG Charts React实时更新柱状图
开发语言·javascript·react.js·图表控件
ywf12151 小时前
Go基础之环境搭建
开发语言·后端·golang
第一程序员1 小时前
Python与前端集成:构建全栈应用
python·github
程序员小远1 小时前
Jmeter基础:Jmeter聚合报告详解
自动化测试·软件测试·python·测试工具·jmeter·测试用例·压力测试
凌波粒1 小时前
D2L学习笔记:安装、张量与数据处理
笔记·python·学习·pandas
是有头发的程序猿1 小时前
用Open Claw接口做1688选品、价格监控、货源对比
开发语言·c++·人工智能
coderlin_2 小时前
从0开始构建Claude Code
python·ai编程