模拟键盘与鼠标输入,并顺带检测输入。
Project description
Simulate input (siminput)
模拟键盘与鼠标输入,并顺带检测输入。
系统要求
支持的平台
- 操作系统:Windows 10/11(64位)
- 架构:x64/AMD64
- Python:3.14 或更高版本
不支持的平台
- 32位 Windows 系统
- Linux 或 macOS
- ARM 架构 Windows
- Python 2.x
安装
从PyPI安装(推荐)
pip install siminput
验证安装
PowerShell
python -c "try:`n import siminput`n print('安装成功')`nexcept:`n print('安装失败,请运行 pip install siminput')"
命令提示符(cmd)或其它
python -c "import siminput; print('安装成功')"
如果报错提示ModuleNotFoundError: No module named 'siminput'则代表安装失败,请运行pip install siminput。
快速开始
基础示例
import siminput
import time
keyname = {
"enter": 13,
"e": 69,
"n": 78,
"t": 84,
"r": 82
}
events = [
{"keycode": keyname["e"], "flag": "keydown"},
{"keycode": keyname["e"], "flag": "keyup"},
{"keycode": keyname["n"], "flag": "keydown"},
{"keycode": keyname["n"], "flag": "keyup"},
{"keycode": keyname["t"], "flag": "keydown"},
{"keycode": keyname["t"], "flag": "keyup"},
{"keycode": keyname["e"], "flag": "keydown"},
{"keycode": keyname["e"], "flag": "keyup"},
{"keycode": keyname["r"], "flag": "keydown"},
{"keycode": keyname["r"], "flag": "keyup"}
]
while True:
time.sleep(0.001)
if siminput.getkeyboard(keyname["enter"]) == "keydown":
while siminput.getkeyboard(keyname["enter"]) == "keydown":
time.sleep(0.1)
siminput.simkeyboard(events)
API 参考
getkeyboard函数
获取键盘按键状态。
参数
keycode:按键码。
返回值
"keydown":按键码对应按键当前处于按下状态。"keyup":按键码对应按键当前处于弹起状态。
simkeyboard函数
模拟发送一组键盘事件。
参数
events:一组按键事件。
返回值
- 成功发送的按键数量。
备注
- 以下是参数
events的结构。此内容代表按下并弹起 A 键,然后按下并弹起 B 键。
[
{
"keycode": 65, # A 的按键码
"flag": "keydown" # 按下
},
{
"keycode": 65, # A 的按键码
"flag": "keyup" # 弹起
},
{
"keycode": 66, # B 的按键码
"flag": "keydown" # 按下
},
{
"keycode": 66, # B 的按键码
"flag": "keyup" # 弹起
},
]
更新日志
最近版本
- v0.0.1 (2025-12-30):
-
- 基础功能发布。
许可证
这是专有软件。请查看 LICENSE 文件了解详细条款。
重要: 使用本软件即表示您同意遵守许可证条款。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
siminput-0.0.1.tar.gz
(19.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file siminput-0.0.1.tar.gz.
File metadata
- Download URL: siminput-0.0.1.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca2cb0eed89d16328b975603a0510fc1b6f51a9bf81e329bcaede24b4772fad1
|
|
| MD5 |
3d313a6016b1428cdc717246ce99e7d0
|
|
| BLAKE2b-256 |
e460786a890dd10d72080af93335cfc925eaea4475b5fd51a7a476843fe09054
|
File details
Details for the file siminput-0.0.1-py3-none-win_amd64.whl.
File metadata
- Download URL: siminput-0.0.1-py3-none-win_amd64.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b403739b57491911e3977470d092c9b22de9dcc18c57b218a3d6876928b65d67
|
|
| MD5 |
e2b60e635c17d444d3c684069e288b9b
|
|
| BLAKE2b-256 |
24585b2f60fd8720919c243b801b21ccce1e4d23a3fcf53f941cdadfbca9cc71
|