简体   繁体   中英

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.

However, you can make a Discord api even trigger when another "software" detects your keystroke. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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