首页 > Windows开发 > 详细

pyqt在windows下的cmd相关

时间:2018-09-17 11:06:40      阅读:305      评论:0      收藏:0      [点我收藏+]

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相关

原文:https://www.cnblogs.com/moon-fire/p/9660748.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!