利用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
相关推荐
catchadmin6 分钟前
Laravel12 + Vue3 的免费可商用商业级管理后台 CatchAdmin V5 正式发布
开发语言·php
袁气满满~_~8 分钟前
Python数据分析学习
开发语言·笔记·python·学习
axinawang37 分钟前
二、信息系统与安全--考点--浙江省高中信息技术学考(Python)
python·浙江省高中信息技术
寻星探路1 小时前
【算法专题】滑动窗口:从“无重复字符”到“字母异位词”的深度剖析
java·开发语言·c++·人工智能·python·算法·ai
程序员小白条1 小时前
面试 Java 基础八股文十问十答第八期
java·开发语言·数据库·spring·面试·职场和发展·毕设
Dxy12393102161 小时前
python连接minio报错:‘SSL routines‘, ‘ssl3_get_record‘, ‘wrong version number‘
开发语言·python·ssl
大王小生1 小时前
C# CancellationToken
开发语言·c#·token·cancellation
listhi5201 小时前
基于C#实现屏幕放大镜功能
开发语言·c#
吨吨不打野1 小时前
CS336——2. PyTorch, resource accounting
人工智能·pytorch·python
___波子 Pro Max.1 小时前
Python文件读取代码中strip()的作用
python