通过HotKey快速运行Python脚本 [英] Run Python script quickly via HotKey
问题描述
我创建了一个简单的脚本,该脚本执行移动的鼠标和键盘"序列.尽管目前要使它正常工作,但我还是使用Shell(空闲)来运行,这会降低启动时间等.
I've created a simple script that executes a "moving mouse and keyboard" sequence. Although currently to get this to work I use a Shell (Idle) to run and that is to slow with boot up time and such.
有没有一种方法可以通过热键快速在桌面och上运行此python文件?我尝试通过终端执行此操作,但它不喜欢我的模块.
Is there a way to have this python file on desktop och with a hotkey swiftly run the code? I tried doing it through terminal but it doesn't like my module.
一些信息: 这适用于Mac和Windows.
Some info: This is for both mac and windows.
我导入的模块是来自PyPi的pyautogui,它在外壳中有效.
The module I imported is pyautogui from PyPi and it works in the shell.
提前谢谢!
推荐答案
尝试设置热键以成功执行任何类型的命令时,需要考虑以下几点:
Some things to consider when trying to setup a hotkey to successfully execute any kind of command:
每个操作系统都有自己的设置热键的方式,有时这在发行版之间以及在桌面管理器之间可能有所不同.
Each Operating System has its own ways to setup hotkeys and sometimes this may differ between distributions as well as between desktop managers.
许多相关的操作说明可通过Google等常规搜索设备轻松找到.
Many of the relevant how-to-descriptions are easily found via regular search machines as Google.
实际上,如果您希望脚本设置自己的热键,则必须以一种方式对其进行重新编写,使其可以自行检测当前的操作系统/发行版/桌面管理器并执行相关的命令.该特定设置.
If you would in fact like your script to set-up its own hotkeys you would have to re-write it in such a manner that it can detect the current operating system/distribution/desktop manager by itself and execute the commands relevant to that particular set-up.
这篇关于通过HotKey快速运行Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!