利用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
相关推荐
mortimer1 分钟前
用 PySide6 打造可视化 ASS 字幕样式编辑器:从需求到实现
python·ffmpeg·pyqt
清空mega10 分钟前
从零开始搭建 flask 博客实验(2)
后端·python·flask
jiushun_suanli12 分钟前
PyTorch CV模型实战全流程(二)
人工智能·pytorch·python
星竹晨L17 分钟前
C++继承机制:面向对象编程的基石
开发语言·c++
咚咚王者31 分钟前
人工智能之编程基础 Python 入门:第三章 基础语法
人工智能·python
G_dou_44 分钟前
Rust安装
开发语言·后端·rust
小白黑科技测评1 小时前
2025 年编程工具实测:零基础学习平台适配性全面解析!
java·开发语言·python
ejinxian2 小时前
Python 3.14 发布
java·开发语言·python
喜欢读源码的小白2 小时前
【Spring Boot + Spring Security】从入门到源码精通:藏经阁权限设计与过滤器链深度解析
java·开发语言·spring boot·spring security
NEU-UUN2 小时前
C语言 . 第二章第二节 . 分支结构
c语言·开发语言