import sys
from PyQt5.QtWidgets import QApplication, QWidget
from ctypes import *
##成功了
class App(QWidget):
def __init__(self):
super().__init__()
self.left=50
self.top=50
self.width=1200
self.height=800
self.initUI()
def initUI(self):
self.setGeometry(self.left,self.top,self.width,self.height)
self.show()
if __name__=='__main__':
FindWindow = windll.user32.FindWindowW
SetParent = windll.user32.SetParent
SetWindowPos = windll.user32.SetWindowPos
#这 里得打开一个“无标题 - 记事本”的笔记本
# 这里得提前打开一个名为“aaa.docx - Word”的word文件,在任务管理器看看,名字必须一致,然后才能嵌入
notepad_handle = FindWindow(0, "aaa.docx - Word")
#notepad_handle = FindWindow(0, "计算器")
app = QApplication(sys.argv)
ex = App()
SetParent(notepad_handle, int(ex.winId()))
SetWindowPos(notepad_handle, 0, 100, 100, 400, 600, 0)
sys.exit(app.exec_())
效果