简体   繁体   English

我将如何创建一个在 python 中运行异步函数的键盘快捷键?

[英]How would I create a keyboard shortcut that runs an async function in python?

目前正在制作一个 Discord 机器人,发送消息的功能必须“等待”,我想将它绑定到键盘快捷键,我将如何去做。

This is not possible in the way you would expect it, bc the discord api is not able to view your keystrokes.这是不可能的,因为 discord api 无法查看您的击键。

However, you can make a Discord api even trigger when another "software" detects your keystroke.但是,您甚至可以在另一个“软件”检测到您的击键时触发 Discord api。 however the script would have to run in the background whenever you want to use the shortcut.但是,只要您想使用快捷方式,脚本就必须在后台运行。

I suggest using Pynput to detect / simulate keystrokes.我建议使用Pynput来检测/模拟击键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM