猿问

python中用“os.system”调用后,如何不阻塞?

 python中用“os.system”调用后,如何不阻塞?

我试过os.system os.popen和subprocess.Popen,都不行,我用来打开cmd,打开之后在里面用win32api输入,可是总是会阻塞,只能等到我把cmd关掉之后才能在IDLE中打字。下面是源文件,小白新手,求解。这是个打开画图板的操作。

import os
import subprocess
import time
import win32api
import win32con
subprocess.Popen("cmd.exe")
win32api.keybd_event(16,0,0,0)
win32api.keybd_event(16,0,win32con.KEYEVENTF_KEYUP,0)
win32api.keybd_event(87,0,0,0)
win32api.keybd_event(87,0,win32con.KEYEVENTF_KEYUP,0)
win32api.keybd_event(82,0,0,0)
win32api.keybd_event(82,0,win32con.KEYEVENTF_KEYUP,0)
win32api.keybd_event(73,0,0,0)
win32api.keybd_event(73,0,win32con.KEYEVENTF_KEYUP,0)
win32api.keybd_event(84,0,0,0)
win32api.keybd_event(84,0,win32con.KEYEVENTF_KEYUP,0)
win32api.keybd_event(69,0,0,0)
win32api.keybd_event(69,0,win32con.KEYEVENTF_KEYUP,0)
win32api.keybd_event(108,0,0,0)
win32api.keybd_event(108,0,win32con.KEYEVENTF_KEYUP,0)


cmdmt
浏览 8983回答 1
1回答

cmdmt

求回答
随时随地看视频慕课网APP

相关分类

Python
我要回答