将Python脚本作为Windows后台进程运行 [英] Running Python Script as a Windows background process

查看:495
本文介绍了将Python脚本作为Windows后台进程运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试编写一个从串行端口读取数据的python脚本.它在命令行上运行良好,但是我需要它作为后台进程运行,而没有任何命令行界面.该脚本有一个while循环,该循环从串行端口读取下一个数据字节,并相应地模拟按键.为了使按键专注于当前窗口,而不是python命令行,我需要脚本作为后台进程运行.我在这里读的答案很少,但是没有什么让我感到振奋.请指出正确的方向.

I have been trying to code a python script which reads data from a serial port. It worked well from the command line but I need it to run as a background process without any command line interface. The script has a while loop which reads the next byte of data from a serial port and simulates a key press accordingly. For the keypresses to be focused on the current window, instead of python command line, I need the script to run as a background process. I have read few answers here but nothing rang a bell for me. Please point me in the right direction.

推荐答案

在Windows上,您可以使用pythonw.exe可执行文件在后台运行Python脚本.这将在后台运行您的程序,而没有可见的过程或与之交互的方式.如果没有系统监视器,也无法终止它.有关pythonw.exe的更多信息,请点击此处: pythonw.exe还是python.exe?

On Windows, you can run a Python script in the background using the pythonw.exe executable. This will run your program in the background, with no visible process or way to interact with it. You also cannot terminate it without a system monitor. More information on pythonw.exehere: pythonw.exe or python.exe?

祝你好运!

这篇关于将Python脚本作为Windows后台进程运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆