pyqt在windows下的cmd相关
Posted moon-fire
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pyqt在windows下的cmd相关相关的知识,希望对你有一定的参考价值。
1. cmd调用
(1)
shell_cmd = ‘...‘
cmd = shlex.split(shell_cmd)
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while p.poll() is None:
line = p.stdout.readline()
line = line.strip()
if line:
s1 = str(line, encoding=‘utf-8‘) # encoding=‘gb2312‘
resture += s1
(2)模拟双击
CREATE_NO_WINDOW = 0x08000000
os.startfile("。。。.exe")
time.sleep(2)
subprocess.call(‘taskkill /F /IM 。。。.exe‘, creationflags=CREATE_NO_WINDOW)
2.打包后的cmd隐藏
几种方法组合食用效果更佳:
(1)
import ctypes
whnd = ctypes.windll.kernel32.GetConsoleWindow()
if whnd != 0:
ctypes.windll.user32.ShowWindow(whnd, 0)
ctypes.windll.kernel32.CloseHandle(whnd)()
(2)
shell_cmd = ‘...‘
cmd = shlex.split(shell_cmd)
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while p.poll() is None:
line = p.stdout.readline()
line = line.strip()
if line:
s1 = str(line, encoding=‘utf-8‘) # encoding=‘gb2312‘
resture += s1
(3)
CREATE_NO_WINDOW = 0x08000000
subprocess.call(‘taskkill /F /IM test8_btc.exe‘, creationflags=CREATE_NO_WINDOW)
(4) spec文件
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name=‘test_addr‘,
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False ) # console置为False
以上是关于pyqt在windows下的cmd相关的主要内容,如果未能解决你的问题,请参考以下文章