利用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
相关推荐
刹那间的回眸x.y2 分钟前
UnitTestReport挺好用
python
世转神风-12 分钟前
qt-在字符串中指定位置插入字符串
开发语言·qt
时光呀时光慢慢走15 分钟前
C# WinForms 实战:MQTTS 客户端开发(与 STM32 设备通信)
开发语言·c#
码农水水25 分钟前
腾讯Java面试被问:阻塞队列BlockingQueue的实现原理
java·后端·python·面试
曲幽28 分钟前
Flask登录验证实战:从零构建一个基础的账号密码登录系统
python·flask·web·session·username·login
superman超哥36 分钟前
仓颉类型别名的使用方法深度解析
c语言·开发语言·c++·python·仓颉
LFly_ice40 分钟前
Next-4-路由导航
开发语言·前端·javascript
卡尔特斯1 小时前
pyenv 安装的 python 版本缺少 tkinter 报错 import _tkinter # If this fails your Python xxx
python
3824278271 小时前
python :__call__方法
开发语言·python
是Yu欸1 小时前
从Ascend C算子开发视角看CANN的“软硬协同”
c语言·开发语言·云原生·昇腾·ascend·cann·开放社区