Is it possible to minimize the console in python with the standard librairy (without extra module)?(是否可以使用标准库(没有额外的模块)最小化 python 中的控制台?)
问题描述
我编写了一个使用控制台的程序.大多数时候,用户必须看到控制台信息.对于命令行中的特定功能,我想在没有控制台升起的情况下运行脚本.我只是不想看到窗口,但它可以在任务栏中.我知道我可以使用额外的模块(gui、win32、..)来做到这一点,但我想使用标准的 python 库.
I wrote a program that uses the console. Most of the time, the user must see the console informations. For a specific function from command line, I would like to run the script without the console rises. I just don't want see the window but it can be in the task bar. I know I can use extra modules (gui, win32,..) to do that but I would like to use the standard python librairy.
有可能吗?
该程序应在 Windows 上运行.(python 2.7)
The program should run on Windows. (python 2.7)
我指定...我知道我也可以使用 pythonw.exe.那么问题是如何有时使用 python.exe 和 pythonw.exe(从命令行)为特定功能启动相同的脚本?
I specify... I know I can use pythonw.exe too. The question then is how to launch the same script with python.exe sometimes and with pythonw.exe (from command line) for a specific function?
推荐答案
通过google找到这个问题,所以回答这个问题,如何在运行Python脚本时最小化(不完全隐藏)Windows上的控制台窗口:
Found this question via google, so to answer the question, how to minimize (not completely hide) the console window on Windows when running a Python script:
# Python 3
import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 6 )
GetConsoleWindow() 将返回当前控制台的窗口句柄.
ShowWindow(hWnd, nCmdShow) 将为特定窗口设置属性.6
是 SW_MINIMIZE
.其他参数点击链接.
GetConsoleWindow() will return the window handle for the current console.
ShowWindow(hWnd, nCmdShow) will set the properties for the specific window. 6
is SW_MINIMIZE
. Click on the link for other parameters.
这篇关于是否可以使用标准库(没有额外的模块)最小化 python 中的控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以使用标准库(没有额外的模块)最小化 p


- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- 沿轴计算直方图 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01