示例#1
0
 def __init__(self, WindowsName=None, IntPtr=None):
     self.worker = ""
     self.hwndChild = ""
     self.WindowsName = WindowsName
     progman = win32gui.FindWindow("Progman", None)
     win32gui.SendMessageTimeout(progman, 0x052C, 0, 0,
                                 win32con.SMTO_NORMAL, 1000)
     win32gui.EnumWindows(self.GetHandleWorkerW, None)
     if IntPtr != None:
         win32gui.SetParent(IntPtr, self.worker)
     else:
         win32gui.EnumWindows(self.GetHandleWallpaperWindows, None)
         # print(self.hwndChild)
         win32gui.SetParent(self.hwndChild, self.worker)
示例#2
0
    def onItemDoubleClicked(self, item):
        """列表双击选择事件"""
        # 先移除掉item
        self.windowList.takeItem(self.windowList.indexFromItem(item).row())
        hwnd, phwnd, _, _ = item.text().split('|')
        # 开始嵌入
        self.releaseWidget()
        hwnd, phwnd = int(hwnd), int(phwnd)
        # 嵌入之前的属性
        style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
        exstyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        wrect = win32gui.GetWindowRect(hwnd)[:2] + win32gui.GetClientRect(
            hwnd)[2:]
        print('save', hwnd, style, exstyle, wrect)

        widget = QWidget.createWindowContainer(QWindow.fromWinId(hwnd))
        widget.hwnd = hwnd  # 窗口句柄
        widget.phwnd = phwnd  # 父窗口句柄
        widget.style = style  # 窗口样式
        widget.exstyle = exstyle  # 窗口额外样式
        widget.wrect = wrect  # 窗口位置
        self.layout().addWidget(widget)

        widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
        win32gui.SetParent(hwnd, int(self.winId()))
示例#3
0
    def update_terminal_position():
        nonlocal container_hwnd, DirectUIHWND_in_container_hwnd, terminal_height

        # 执行前需要确保窗口resize过 否则 existed_widget 高度不能恢复,会越来越小

        # 装入容器
        win32gui.SetParent(terminal_hwnd, container_hwnd)

        # 改变容器中树状目录的高度
        (left, top, right, bottom, width,
         height) = get_window_rect_and_size(folder_tree_in_container_hwnd)
        new_container_h = height - terminal_height
        win32gui.MoveWindow(folder_tree_in_container_hwnd, 0, 0, width,
                            new_container_h, 1)

        # 改变容器中的第一个 DirectUIHWND 的高度,给终端腾出位置
        (left, top, right, bottom, width,
         height) = get_window_rect_and_size(DirectUIHWND_in_container_hwnd)
        new_container_h = height - terminal_height
        win32gui.MoveWindow(DirectUIHWND_in_container_hwnd, 0, 0, width,
                            new_container_h, 1)

        # 移动 终端窗口 到刚刚腾出的位置
        win32gui.MoveWindow(terminal_hwnd, 0, new_container_h, width,
                            terminal_height, 1)

        # 改变容器中的第二个 DirectUIHWND 的宽度
        update_sub_DirectUIHWND_position()
示例#4
0
    def Fetch_VP(self):
        import win32gui, win32con

        # Try to find the newly created VPython window
        # which is now a main-application-window
        self.VP = win32gui.FindWindow(None, 'VPython')

        if self.VP:
            w = self.Old_Size[0]
            h = self.Old_Size[1]

            # get the handle of the dock container
            PP = self.p1.GetHandle()

            # Set Position and Size of the VPython window,
            # Before Docking it !!
            #flags = win32con.SWP_ASYNCWINDOWPOS or \
            #        win32con.SWP_SHOWWINDOW     or \
            #        win32con.SWP_FRAMECHANGED
            flags = win32con.SWP_SHOWWINDOW or \
                    win32con.SWP_FRAMECHANGED
            win32gui.SetWindowPos(self.VP, win32con.HWND_TOPMOST, -4, -22,
                                  w + 8, h + 26, flags)

            # Dock the VPython window
            win32gui.SetParent(self.VP, PP)

            # reset the State Machine
            self.VP_State = 0
示例#5
0
    def initUI(self):
        viewId = self.winId()

        workerW = self._findWindowHandles(windowClass='Progman')[0]
        crypticParams = (0x52c, 0, 0, win32con.SMTO_NORMAL, 0x3e8)
        win32gui.SendMessageTimeout(workerW, *crypticParams)
        win32gui.EnumWindows(EnumWindowsProc(), None)
        win32gui.ShowWindow(_WORKERW, win32con.SW_SHOW)

        #win32gui.GetWindowLong(viewId, win32con.GWL_STYLE)
        #win32gui.SetWindowPos(viewId, win32con.HWND_TOP, 0,0,0,0, \
        #    win32con.WS_EX_LEFT|win32con.WS_EX_LTRREADING|win32con.WS_EX_RIGHTSCROLLBAR|win32con.SWP_NOACTIVATE)

        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.CoverWindow
                            | Qt.WindowStaysOnBottomHint)
        self.setWindowState(Qt.WindowNoState)
        self.setFocusPolicy(Qt.NoFocus)

        win32gui.SetParent(viewId, workerW)

        self.load(
            QUrl(
                'C:/Users/Daniil (WORK)/Desktop/Wallpaper3/html/example/index.html'
            ))
        self.showFullScreen()
        self.show()
示例#6
0
 def __init__(self, parent=None):
     QMainWindow.__init__(self, parent)
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setAttribute(Qt.WA_TranslucentBackground)
     self.setFixedSize(self.height(), self.width())
     win32gui.SetParent(self.winId(), utils.getWindowsDeskTopHwnd())
     self.ui = QObject()
示例#7
0
def embedSysWindow(putThisWindow, intoThisWindow):
    """
	Moves a given window to a child of another window.

	On Windows, each window can be:
		integer hwnd
		string hwnd "0x" for hex or just a regular int

	TODO: this should be made to work on any os

	See also:
		https://stackoverflow.com/questions/170800/embedding-hwnd-into-external-process-using-setparent#335724
	"""
    import win32gui
    import win32con
    # make sure we have hwnds
    childHwnd = putThisWindow
    parentHwnd = intoThisWindow
    # Remove WS_POPUP style and add WS_CHILD style
    style = win32gui.GetWindowLong(childHwnd, win32con.GWL_STYLE)
    style &= ~(win32con.WS_POPUP)
    style |= win32con.WS_CHILD
    win32gui.SetWindowLong(childHwnd, win32con.GWL_STYLE, style)
    # set it
    win32gui.SetParent(childHwnd, parentHwnd)
示例#8
0
def _enum_windows(tophandle, topparamhandle):
    p = win32gui.FindWindowEx(tophandle, 0, "SHELLDLL_DefView", None)
    if p != 0:
        workerw = win32gui.FindWindowEx(0, tophandle, "WorkerW", None)
        pyglet_hwnd = window._hwnd
        pyglet_hdc = win32gui.GetWindowDC(pyglet_hwnd)  #
        win32gui.SetParent(pyglet_hwnd, workerw)
    return True
示例#9
0
 def _change_container(self, new_container):
     GComponent._change_container(self, new_container)
     if new_container:
         win_new_parent = new_container._win
     else:
         win_new_parent = win_none
     hwnd = self._win.GetSafeHwnd()
     gui.SetParent(hwnd, win_new_parent.GetSafeHwnd())
     if new_container:
         self._win_move_window(self._bounds)
示例#10
0
def incorporarMatriz(ventana):
    '''------------
    DOCUMENTACIÓN -
    Introduce el proceso de P3 Speller dentro de la ventana Aplicacion de Cognitask.
    - Permite manipular P3 Speller a traves de Cognitask.
    ------------'''
    parent = ventana
    child = win32gui.FindWindow(None, "P3 Speller")
    win32gui.SetParent(child, parent)
    win32gui.SetWindowPos(child, 0, 0, 0, 600, 600, 0)
示例#11
0
def embed(programName):

    desk = win32gui.FindWindow("Progman", "Program Manager")
    background = win32gui.FindWindowEx(desk, 0, "SHELLDLL_DefView", None)

    program = win32gui.FindWindow(None, programName)
    #pyqt5 QWidget.winId()获得program

    win32gui.SendMessage(desk, 0x052c, 0, 0)
    win32gui.EnumWindows(EnumWindowsProc, 0)
    win32gui.SetParent(program, desk)
示例#12
0
    def on_get_connect_click(self):
        ISTYLE = win32gui.GetWindowLong(self.calc_hwnd, win32con.GWL_STYLE)
        win32gui.SetWindowLong(self.calc_hwnd, win32con.GWL_STYLE,
                               ISTYLE & ~win32con.GW_CHILD)
        print(self.calc_hwnd)
        win32gui.SetWindowPos(
            self.calc_hwnd, None, 0, 0, 600, 400,
            win32con.SWP_NOSIZE | win32con.SWP_NOMOVE | win32con.SWP_NOACTIVATE
            | win32con.SWP_FRAMECHANGED)
        RESULT = win32gui.SetParent(self.calc_hwnd, self.winId())

        print(RESULT)
示例#13
0
def renderWallpaper():
    global _handle, _widget, _legacy, _cursorAtDesktop, _wndproc0

    sys.excepthook = cef.ExceptHook  # 替换python预定义异常处理逻辑,为保证异常发生时能够结束所有进程
    cef.Initialize(
        settings={},
        switches={"disable-gpu-compositing": None}  # 添加了用于解决高 DPI 问题的参数
    )

    # 启用 CEF 高 DPI 支持
    cef.DpiAware.EnableHighDpiSupport()

    # 初始化 CEF 浏览器,并设置加载完毕的事件处理代码
    broswer = cef.CreateBrowserSync(url="file:///" + os.getcwd() +
                                    "/Website/website.html")
    broswer.SetClientHandler(LoadHandler())

    # 获得与 CEF 浏览器有关的窗口句柄 (句柄名在 Spy++ 中查找的)
    _handle = broswer.GetWindowHandle()
    _widget = win32gui.FindWindowEx(_handle, 0, "Chrome_WidgetWin_0", None)
    _legacy = win32gui.FindWindowEx(_widget, 0, "Chrome_RenderWidgetHostHWND",
                                    None)

    # 获得屏幕分辨率
    _screenSize[0] = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
    _screenSize[1] = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)

    # 去除浏览器内核边框
    win32gui.SetWindowLong(
        _handle, win32con.GWL_STYLE,
        win32gui.GetWindowLong(_handle, win32con.GWL_STYLE)
        & ~(win32con.WS_CAPTION | win32con.WS_BORDER | win32con.WS_THICKFRAME))

    # 将网页铺满全屏
    win32gui.SetWindowPos(_handle, win32con.HWND_TOP, 0, 0, _screenSize[0],
                          _screenSize[1], win32con.SWP_NOACTIVATE)
    win32gui.SetParent(_handle, _GetWorkerW())

    # 更改 CEF 浏览器的一些行为
    _wndproc0 = win32gui.SetWindowLong(_legacy, win32con.GWL_WNDPROC,
                                       _InputHandler)
    mouseDevice = RAWINPUTDEVICE()
    mouseDevice.usUsagePage = 0x01
    mouseDevice.usUsage = 0x02
    mouseDevice.dwFlags = 0x100
    mouseDevice.hwndTarget = _legacy
    ctypes.windll.user32.RegisterRawInputDevices(ctypes.byref(mouseDevice), 1,
                                                 ctypes.sizeof(mouseDevice))

    cef.MessageLoop()  # 正式启动浏览器

    cef.Shutdown()  # 浏览器关闭后释放资源
示例#14
0
 def embeddedWindow(self):
     while win32gui.FindWindow("StarCraft II", None) == 0:
         pass
     hwnd = win32gui.FindWindow("StarCraft II", None)
     hwnd_qwindow = QWindow.fromWinId(hwnd)
     # hwnd_qwindow.setFlags(Qt.FramelessWindowHint)
     # self.game_widget.createWindowContainer(hwnd_qwindow, self.game_widget)
     # self.game_widget.show()
     phwnd = win32gui.FindWindow('FightView', None)
     print('hwnd: ', hwnd, ' phwnd: ', phwnd)
     win32gui.SetParent(hwnd, phwnd)
     # self.main_layout.addWidget(hwnd_widget)
     QApplication.processEvents()
示例#15
0
 def restore(self):
     """归还窗口"""
     # 有bug,归还后窗口没有了WS_VISIBLE样式,不可见
     widget = self.layout().itemAt(3).widget()
     print('restore', widget.hwnd, widget.style, widget.exstyle)
     win32gui.SetParent(widget.hwnd, widget.phwnd)  # 让它返回它的父窗口
     win32gui.SetWindowLong(widget.hwnd, win32con.GWL_STYLE,
                            widget.style | win32con.WS_VISIBLE)  # 恢复样式
     win32gui.SetWindowLong(widget.hwnd, win32con.GWL_EXSTYLE,
                            widget.exstyle)  # 恢复样式
     win32gui.ShowWindow(widget.hwnd, win32con.SW_SHOW)  # 显示窗口
     widget.close()
     self.layout().removeWidget(widget)  # 从布局中移出
     widget.deleteLater()
示例#16
0
def main():
    time.sleep(3)
    ffplay = win32gui.FindWindow(None, "pynamic_player")
    progman = win32gui.FindWindow("Progman", "Program Manager")
    win32gui.SendMessageTimeout(progman, 0x052C, 0, 0, win32con.SMTO_NORMAL,
                                1000)
    time.sleep(0.1)
    hwnd = win32gui.GetWindow(progman, win32con.GW_HWNDPREV)
    wkwname = win32gui.GetClassName(hwnd)
    print(wkwname)
    if wkwname == "WorkerW":
        win32gui.SetParent(ffplay, hwnd)
        win32gui.SetWindowPos(ffplay, win32con.HWND_BOTTOM, 0, 0, w, h,
                              0 | win32con.SWP_NOZORDER)
示例#17
0
def _create_qt_parent_proxy():
    """
    """
    import sgtk
    sgtk.platform.current_engine().log_debug("Creating Qt parent window proxy")

    global _QT_PARENT_TITLE

    from sgtk.platform.qt import QtGui, QtCore
    proxy_win = QtGui.QWidget()
    proxy_win.setWindowTitle(_QT_PARENT_TITLE)

    if sys.platform == "win32":
        # on windows, we can parent directly to the application:

        # get the main window HWND
        import win32api, win32con, win32gui
        from .win32 import find_windows, qwidget_winid_to_hwnd
        found_hwnds = find_windows(thread_id=win32api.GetCurrentThreadId(),
                                   window_text="Autodesk Softimage",
                                   stop_if_found=False)
        if len(found_hwnds) != 1:
            return
        si_hwnd = found_hwnds[0]

        # convert QWidget winId() to hwnd:
        proxy_win_hwnd = qwidget_winid_to_hwnd(proxy_win.winId())

        # set up the window style
        win_ex_style = win32gui.GetWindowLong(proxy_win_hwnd,
                                              win32con.GWL_EXSTYLE)
        win32gui.SetWindowLong(proxy_win_hwnd, win32con.GWL_EXSTYLE,
                               win_ex_style | win32con.WS_EX_NOPARENTNOTIFY)
        win32gui.SetWindowLong(proxy_win_hwnd, win32con.GWL_STYLE,
                               win32con.WS_CHILD)

        # finally, parent to application window:
        win32gui.SetParent(proxy_win_hwnd, si_hwnd)
    else:
        # not able to parent directly on other os so just set to stay on top:
        proxy_win.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

    # debug to prove that the window is actually parented!
    # proxy_win.show()

    return proxy_win
示例#18
0
    def restore(self):
        """归还窗口"""
        # 有bug,归还后窗口没有了WS_VISIBLE样式,不可见
        widget = self.layout().itemAt(4).widget()
        hwnd, phwnd, style, exstyle, wrect = widget.hwnd, widget.phwnd, widget.style, widget.exstyle, widget.wrect
        print('restore', hwnd, phwnd, style, exstyle, wrect)
        widget.close()
        self.layout().removeWidget(widget)  # 从布局中移出
        widget.deleteLater()

        win32gui.SetParent(hwnd, phwnd)  # 让它返回它的父窗口
        win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE,
                               style | win32con.WS_VISIBLE)  # 恢复样式
        win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exstyle)  # 恢复样式
        win32gui.ShowWindow(hwnd, win32con.SW_SHOW)  # 显示窗口
        win32gui.SetWindowPos(hwnd, 0, wrect[0], wrect[1], wrect[2], wrect[3],
                              win32con.SWP_NOACTIVATE)
示例#19
0
    def Fetch_VP(self):
        w = self.Old_Size[0]
        h = self.Old_Size[1]

        if Platform_Windows:
            import win32gui, win32con
            # Try to find the newly created VPython window
            # which is now a main-application-window
            self.VP = win32gui.FindWindow(None,
                                          visual.scene.title)  #'VPython' )

            if self.VP:
                # reset the State Machine
                self.VP_State = 0

                # get the handle of the dock container
                PP = self.p1.GetHandle()

                # Set Position and Size of the VPython window,
                # Before Docking it !!
                #flags = win32con.SWP_ASYNCWINDOWPOS or \
                #        win32con.SWP_SHOWWINDOW     or \
                #        win32con.SWP_FRAMECHANGED
                flags = win32con.SWP_SHOWWINDOW or \
                        win32con.SWP_FRAMECHANGED
                win32gui.SetWindowPos(self.VP, win32con.HWND_TOPMOST, -4, -22,
                                      w + 8, h + 26, flags)
                #win32gui.MoveWindow ( self.VP, -4, -22, w+8, h+26, True )

                # Dock the VPython window
                win32gui.SetParent(self.VP, PP)

        else:  # not Windows
            self.VP_State = 0
            if not (self.Linux_Message):
                self.Linux_Message = True
                line = """
In this panel the Vpython window
should be captured.
Unfortunately I don't know
how to accomplsh this
under Linux / Mac
"""
                self.Message = wx.StaticText(self.p1)
                self.Message.SetLabel(line)
示例#20
0
def setbk(child, praent):
    win32gui.SetParent(eval(child), eval(praent))
示例#21
0
"""
play video as wallpaper in desktop
require: pywin32
"""

import subprocess
import time
import win32gui
import win32con

r = r"D:\ffmpeg\bin\ffplay.exe D:\thunder\wallpaper\t.mp4 -noborder -x 1920 -y 1080 -loop 0"
subprocess.Popen(r)
time.sleep(.5)

progman = win32gui.FindWindow('Progman', None)
cryptic_params = (0x52c, 0, 0, 0, 100)
win32gui.SendMessageTimeout(progman, *cryptic_params)
ffplay = win32gui.FindWindow('SDL_app', None)
win32gui.SetParent(ffplay, progman)
def_view = win32gui.FindWindowEx(progman, 0, 'SHELLDLL_DefView', None)
if def_view:
    worker_w = win32gui.FindWindowEx(0, progman, 'WorkerW', None)
    win32gui.ShowWindow(worker_w, win32con.SW_HIDE)


示例#22
0
 def embed(self):
     # 获取桌面句柄
     retVar = []
     win32gui.EnumWindows(_MyCallback, retVar)
     # print("HWND: {} ".format(retVar[0]))
     win32gui.SetParent(int(self.winId()), retVar[0])
示例#23
0
import sys
import win32gui
from PyQt5.QtWidgets import QApplication, QWidget

parent = 0


def callback(a, none):
    global parent
    b = win32gui.FindWindowEx(a, 0, "SHELLDLL_DefView", None)
    if b > 0:
        c = win32gui.FindWindowEx(b, 0, "SysListView32", "FolderView")
        parent = c


if __name__ == '__main__':
    app = QApplication(sys.argv)

    w = QWidget()
    w.resize(250, 150)
    w.move(0, 0)
    w.setWindowTitle('First PyQt5')
    w.show()

    win32gui.EnumWindows(callback, None)
    child = win32gui.FindWindow(None, "First PyQt5")
    win32gui.SetParent(child, parent)

    sys.exit(app.exec_())
示例#24
0
def 窗口_置父窗口(子窗口句柄,父窗口句柄):
    '将子窗口嵌入父窗口内'
    return win32gui.SetParent(子窗口句柄, 父窗口句柄)
示例#25
0
    def setup(self, alpha=0xff):
        global hWnd, hDC, hRC, hbitmap

        hwnd = pygame.display.get_wm_info()["window"]
        if SOFTWARE_RENDER:
            hWnd = pygame.display.get_wm_info()["window"]

            hdcwnd = win32gui.GetDC(hWnd)
            hDC = win32gui.CreateCompatibleDC(hdcwnd)

            win32gui.SetWindowLong(
                hWnd, win32con.GWL_EXSTYLE,
                win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE)
                | win32con.WS_EX_LAYERED)

            bmi = BITMAPINFO()
            bmi.bmiHeader.biSize = ctypes.sizeof(BITMAPINFOHEADER)
            bmi.bmiHeader.biWidth = self.WIDTH
            bmi.bmiHeader.biHeight = self.HEIGHT
            bmi.bmiHeader.biPlanes = 1
            bmi.bmiHeader.biBitCount = 32
            bmi.bmiHeader.biCompression = win32con.BI_RGB
            bmi.bmiHeader.biSizeImage = self.WIDTH * self.HEIGHT * 4
            hbitmap = ctypes.windll.gdi32.CreateDIBSection(
                hDC, ctypes.byref(bmi), win32con.DIB_RGB_COLORS,
                ctypes.byref(ctypes.c_void_p()), None, 0)
            win32gui.SelectObject(hDC, hbitmap)

            PFD_TYPE_RGBA = 0
            PFD_MAIN_PLANE = 0
            PFD_DRAW_TO_BITMAP = 0x00000008
            PFD_SUPPORT_GDI = 0x00000010
            PFD_SUPPORT_OPENGL = 0x00000020

            dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI

            pfd = PIXELFORMATDESCRIPTOR()
            pfd.nSize = ctypes.sizeof(PIXELFORMATDESCRIPTOR)
            pfd.nVersion = 1
            pfd.dwFlags = dwFlags
            pfd.iPixelType = PFD_TYPE_RGBA
            pfd.cColorBits = 32
            pfd.cDepthBits = 32
            pfd.cStencilBits = 8
            pfd.iLayerType = PFD_MAIN_PLANE

            # hdc = win32gui.GetDC(hWnd)
            pixelformat = ChoosePixelFormat(hDC, pfd)
            SetPixelFormat(hDC, pixelformat, pfd)
            hRC = wglCreateContext(hDC)
            # win32gui.ReleaseDC(hWnd, hdc)
            wglMakeCurrent(hDC, hRC)

            win32gui.ShowWindow(hwnd, win32con.SW_SHOWNOACTIVATE)
            win32gui.SetWindowPos(
                hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0,
                win32con.SWP_NOSIZE | win32con.SWP_NOACTIVATE)

            cur_style = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
            win32gui.SetWindowLong(
                hwnd, win32con.GWL_EXSTYLE, cur_style
                | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED)
        else:
            win32gui.SetWindowLong(
                hwnd, win32con.GWL_EXSTYLE,
                win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
                | win32con.WS_EX_LAYERED | win32con.WS_EX_TOOLWINDOW)
            win32gui.SetParent(hwnd, win32con.NULL)
            win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(*COLORKEY),
                                                0, win32con.LWA_COLORKEY)

            win32gui.ShowWindow(hwnd, win32con.SW_SHOWNOACTIVATE)
            win32gui.SetWindowPos(
                hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0,
                win32con.SWP_NOSIZE | win32con.SWP_NOACTIVATE)

            cur_style = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
            win32gui.SetWindowLong(
                hwnd, win32con.GWL_EXSTYLE, cur_style
                | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED)
示例#26
0
文件: cmdC.py 项目: Y-Scorpion/ScanIp
import os, time, win32gui
from subprocess import Popen
from PyQt5 import QtWidgets
# root_dir = os.environ.get("SystemRoot",r"C:\\WINDOWS")
# calc = r'%s\\System32\\calc.exe' % root_dir
# Popen(calc)
# time.sleep(1)
#Get window handle of calc window
calc_hwnd = win32gui.FindWindow(None, u"C:\WINDOWS\system32\cmd.exe")
print(calc_hwnd)
#Creat QT Application
a = QtWidgets.QApplication([])
mainwin = QtWidgets.QMainWindow()
#Set QT mainwindow as parent of calc window
print(int(mainwin.winId()))
win32gui.SetParent(calc_hwnd, int(mainwin.winId()))

mainwin.showMaximized()
mainwin.show()
#Convert calc into QT widget
wgt = mainwin.find(calc_hwnd)
#XXX: following print gives "None"
print(type(wgt))
a.exec_()