- 需要获取要运行的exe的类名(自行查阅)
运行代码:
主要的,需要修改的部分都在代码中进行了说明。
def runExe():
exePath = os.path.join(os.path.dirname(__file__), 'exe', 'text.exe') #'exe'+'text.exe'为"exe/text.exe" exe文件的路径
print('exePath ',exePath)
subprocess.Popen(exePath)
class Main(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.setupUi((self))
self.start.clicked.connect(self.init_unity)
def init_unity(self):
t = multiprocessing.Process(target=runExe)
t.start()
hwnd1 = win32gui.FindWindow("GHOST_WindowClass", 'text') #"GHOST_WindowClass"导入的外部的exe文件的类,'text'要运行的外部文件的名字
while(hwnd1 == 0) :
hwnd1 = win32gui.FindWindow("GHOST_WindowClass", 'text')
window = QtGui.QWindow.fromWinId(hwnd1)
self.frame = QtWidgets.QFrame.createWindowContainer(window)
self.layout = QVBoxLayout(self.label)
self.layout.addWidget(self.frame)
- 希望能帮到大家~
- 有什么可以私信或评论哦~看到会回复
- 需要完整代码(包括ui文件),后台私信