Beispiel #1
0
def hide_from_taskbar(hw):
    try:
        win32gui.ShowWindow(hw, SW_HIDE)
        win32gui.SetWindowLong(
            hw, GWL_EXSTYLE,
            win32gui.GetWindowLong(hw, GWL_EXSTYLE) | WS_EX_TOOLWINDOW)
        win32gui.ShowWindow(hw, SW_SHOW)
    except win32gui.error:
        return None
Beispiel #2
0
    def getWindow_Img_new(self, Emu_Index):
        self.Hwnd = int(self.Get_Self_Hawd(Emu_Index))

        # 將 hwnd 換成 WindowLong
        s = win32gui.GetWindowLong(self.Hwnd, win32con.GWL_EXSTYLE)
        win32gui.SetWindowLong(self.Hwnd, win32con.GWL_EXSTYLE,
                               s | win32con.WS_EX_LAYERED)
        # 判斷視窗是否最小化
        show = win32gui.IsIconic(self.Hwnd)
        # 將視窗圖層屬性改變成透明
        # 還原視窗並拉到最前方
        # 取消最大小化動畫
        # 取得視窗寬高
        if show == 1:
            win32gui.SystemParametersInfo(win32con.SPI_SETANIMATION, 0)
            win32gui.SetLayeredWindowAttributes(self.Hwnd, 0, 0,
                                                win32con.LWA_ALPHA)
            win32gui.ShowWindow(self.Hwnd, win32con.SW_RESTORE)
            x, y, width, height = self.getWindow_W_H(self.Hwnd)
    # 創造輸出圖層
        hwindc = win32gui.GetWindowDC(self.Hwnd)
        srcdc = win32ui.CreateDCFromHandle(hwindc)
        memdc = srcdc.CreateCompatibleDC()
        bmp = win32ui.CreateBitmap()
        # 取得視窗寬高
        x, y, width, height = self.getWindow_W_H(self.Hwnd)
        # 如果視窗最小化,則移到Z軸最下方
        if show == 1:
            win32gui.SetWindowPos(self.Hwnd, win32con.HWND_BOTTOM, x, y, width,
                                  height, win32con.SWP_NOACTIVATE)
        # 複製目標圖層,貼上到 bmp
        bmp.CreateCompatibleBitmap(srcdc, width, height)
        memdc.SelectObject(bmp)
        memdc.BitBlt((0, 0), (width, height), srcdc, (8, 3), win32con.SRCCOPY)
        # 將 bitmap 轉換成 np
        signedIntsArray = bmp.GetBitmapBits(True)
        img = np.fromstring(signedIntsArray, dtype='uint8')
        img.shape = (height, width, 4)  #png,具有透明度的

        # 釋放device content
        srcdc.DeleteDC()
        memdc.DeleteDC()
        win32gui.ReleaseDC(self.Hwnd, hwindc)
        win32gui.DeleteObject(bmp.GetHandle())
        # 還原目標屬性
        if show == 1:
            win32gui.SetLayeredWindowAttributes(self.Hwnd, 0, 255,
                                                win32con.LWA_ALPHA)
            win32gui.SystemParametersInfo(win32con.SPI_SETANIMATION, 1)

    # 回傳圖片
    #src_img = img
    #src_img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    #src_img = cv2.imwrite('test1.jpg',img)
    #self.ScreenHot = img
        return img
def windowEnumerationHandler(hwnd, top_windows):
    clsName = win32gui.GetClassName(hwnd)
    winStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
    if clsName == 'mintty' and winStyle & win32con.WS_VISIBLE:
        threadId, processId = win32process.GetWindowThreadProcessId(hwnd)
        procHdl = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
                                       False, processId)
        info = win32process.GetProcessTimes(procHdl)
        top_windows.append((hwnd, info['CreationTime'], clsName,
                            win32gui.GetWindowText(hwnd)))
Beispiel #4
0
def set_window_boring_stuff():
    hwnd = pygame.display.get_wm_info()["window"]
    win32gui.SetWindowLong(
        hwnd, win32con.GWL_EXSTYLE,
        win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        | win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(*fuchsia), 0, win32con.LWA_COLORKEY)\

    win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0,
                          win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
    def setEdgeSnapping(self, value: bool):
        """Enable or disable edge snapping for window.

        Args:
            value (bool): Enable or disable edge snapping.
        """
        if not self.hwnd:
            self.__setStyle()

        if value:
            style = win32gui.GetWindowLong(self.hwnd, win32con.GWL_STYLE)
            win32gui.SetWindowLong(self.hwnd, win32con.GWL_STYLE,
                                   style | win32con.WS_TILEDWINDOW)
        else:
            style = win32gui.GetWindowLong(self.hwnd, win32con.GWL_STYLE)
            win32gui.SetWindowLong(
                self.hwnd, win32con.GWL_STYLE,
                style & ~win32con.WS_OVERLAPPEDWINDOW
                | win32con.WS_POPUPWINDOW)
Beispiel #6
0
 def mouseTrans(self):
     self.mouseFlag = False if self.mouseFlag else True
     if (self.mouseFlag):
         #设置鼠标穿透
         self.a3.setIcon(QIcon('./img/uncheck.png'))
         self.a3.setText(self.a3Text1)
         # self.setAttribute(Qt.WA_TransparentForMouseEvents,True)
         win32gui.SetWindowLong(
             self.winId(), win32con.GWL_EXSTYLE,
             win32gui.GetWindowLong(self.winId(), win32con.GWL_EXSTYLE)
             | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED)
     else:
         self.a3.setIcon(QIcon('./img/check.png'))
         self.a3.setText(self.a3Text2)
         # self.setAttribute(Qt.WA_TransparentForMouseEvents,False)
         win32gui.SetWindowLong(
             self.winId(), win32con.GWL_EXSTYLE,
             win32gui.GetWindowLong(self.winId(), win32con.GWL_EXSTYLE) &
             (~win32con.WS_EX_TRANSPARENT) & (~win32con.WS_EX_LAYERED))
Beispiel #7
0
 def make_transparent(self):
     style = win32gui.GetWindowLong(self.window, win32con.GWL_EXSTYLE)
     win32gui.ShowWindow(self.window, win32con.SW_HIDE)
     style |= win32con.WS_EX_COMPOSITED | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_TOOLWINDOW | win32con.WS_EX_NOACTIVATE
     style &= ~win32con.WS_EX_APPWINDOW
     win32gui.SetWindowLong(self.window, win32con.GWL_EXSTYLE, style)
     sleep(1)
     win32gui.ShowWindow(self.window, win32con.SW_SHOW)
     winxpgui.SetLayeredWindowAttributes(self.window, 0, 0,
                                         win32con.LWA_ALPHA)
Beispiel #8
0
def test(hWnd, windows):
    if not isRealWindows(hWnd):
        return
    windows.append(hWnd)
    win32gui.SetWindowLong(
        hWnd, win32con.GWL_EXSTYLE,
        win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE)
        | win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hWnd, win32api.RGB(0, 0, 0), 0,
                                        win32con.LWA_ALPHA)
 def gethwnd(self):
     self.hwnd = self.root.winfo_id()
     p = win32gui.GetWindowLong(self.hwnd, win32con.GWL_EXSTYLE)
     if not (p & win32con.WS_EX_LAYERED):
         win32gui.SetWindowLong(self.hwnd, win32con.GWL_EXSTYLE,
                                p | win32con.WS_EX_LAYERED)
     win32gui.SetLayeredWindowAttributes(
         self.hwnd, win32api.RGB(0, 0, 0), int(200),
         win32con.LWA_ALPHA | win32con.LWA_COLORKEY)
     self.root.update()
Beispiel #10
0
 def isRealWindow(self, hWnd):  # Thanks DzinX from stackoverflow.
     """Return True if given window is a real Windows application window."""
     if not win32gui.IsWindowVisible(hWnd) or win32gui.GetParent(hWnd) != 0:
         return False
     hasNoOwner = win32gui.GetWindow(hWnd, win32con.GW_OWNER) == 0
     lExStyle = win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE)
     if (((lExStyle & win32con.WS_EX_TOOLWINDOW) == 0 and hasNoOwner) or
         ((lExStyle & win32con.WS_EX_APPWINDOW != 0) and not hasNoOwner)):
         if win32gui.GetWindowText(hWnd): return True
     return False
Beispiel #11
0
 def EnumWindowsCallback(hwnd, params):
     wflags = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
     if not (wflags & win32con.WS_VISIBLE): return True
     sndWnd = win32gui.FindWindowEx(hwnd, None, "SHELLDLL_DefView", None)
     if not sndWnd: return True
     targetWnd = win32gui.FindWindowEx(sndWnd, None, "SysListView32",
                                       "FolderView")
     if not targetWnd: return True
     params.append(targetWnd)
     return True
Beispiel #12
0
    def transparent_mode(self):
        opt = Options()

        SetWindowPos = windll.user32.SetWindowPos
        hwnd = pygame.display.get_wm_info()["window"]
        win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED)
        win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(44, 44, 0), 0, win32con.LWA_COLORKEY) # RGB(44, 44, 0) = #2C2C00
        win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, opt.x_position, opt.y_position, opt.width, opt.height, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) # Always set it on the top, useful when playing in fullscreen 

        self.screen.fill(DrawingTool.color("#2C2C00")) # This color is a good comprise between readability and performances. Somehow, using black or white make the tracker not responding.
Beispiel #13
0
 def set_window_alpha(self, wildcard, alpha_val=180):
     self.reset()
     self.find_window_wildcard(wildcard)
     self.set_foreground()
     win32gui.SetWindowLong(
         self._handle, win32con.GWL_EXSTYLE,
         win32gui.GetWindowLong(self._handle, win32con.GWL_EXSTYLE)
         | win32con.WS_EX_LAYERED)
     winxpgui.SetLayeredWindowAttributes(self._handle,
                                         win32api.RGB(0, 0, 0), alpha_val,
                                         win32con.LWA_ALPHA)
Beispiel #14
0
def move_transparent_window(x, y, fuchsia):

    SetWindowPos = windll.user32.SetWindowPos
    hwnd = pygame.display.get_wm_info()["window"]
    win32gui.SetWindowLong(
        hwnd, win32con.GWL_EXSTYLE,
        win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        | win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(*fuchsia), 0,
                                        win32con.LWA_COLORKEY)
    SetWindowPos(hwnd, -1, x, y, 0, 0, 0x0001)
Beispiel #15
0
def get_windowstate(hwnd):
    statu = "正常"
    if not gui.IsWindowVisible(hwnd):
        statu = "隐藏"
    if gui.IsIconic(hwnd):
        statu = "最小化"
    if (gui.GetWindowLong(hwnd, con.GWL_EXSTYLE) & con.WS_EX_TOPMOST) != 0:
        statu = "置顶"
    if gui.GetForegroundWindow() == hwnd:
        statu = "活动窗口"
    return statu
Beispiel #16
0
def turn_on_double_buffering_on_windows(window):
    # This has actually an adverse effect when Aero is enabled...
    from ctypes import wintypes
    dll = ctypes.WinDLL('dwmapi.dll')
    ret = wintypes.BOOL()
    if dll.DwmIsCompositionEnabled(ctypes.pointer(ret)) == 0 and ret.value:
        return
    import win32gui, win32con  # pylint: disable=F0401
    exstyle = win32gui.GetWindowLong(window.GetHandle(), win32con.GWL_EXSTYLE)
    exstyle |= win32con.WS_EX_COMPOSITED
    win32gui.SetWindowLong(window.GetHandle(), win32con.GWL_EXSTYLE, exstyle)
Beispiel #17
0
    def get_property(self, element, propertyName):
        valid_properties = [
            'TEXT', 'TYPE', 'CLASSNAME', 'VISIBLE', 'RECT', 'TOPLEVELWINDOW',
            'ACTIVE'
        ]
        name = propertyName.upper()
        if name not in valid_properties:
            raise ValueError('%s not supported!' % name)

        if isinstance(element, int) and not win32gui.IsWindow(element):
            return None

        result = None
        if name == 'TEXT':
            result = self.__get_text(element)

        elif name in ['CLASSNAME', 'TYPE']:
            result = self.__encode_locale(win32gui.GetClassName(element))

        elif name == 'VISIBLE':
            result = True if win32gui.IsWindowVisible(element) == 1 else False

        elif name == 'RECT':
            result = win32gui.GetWindowRect(element)

        elif name == 'TOPLEVELWINDOW':
            if isinstance(element, int):
                style = win32gui.GetWindowLong(element, win32con.GWL_STYLE)
                if (style & win32con.WS_CHILDWINDOW) == 0:
                    return element

                if element == win32gui.GetDesktopWindow():
                    return None

                parent = element
                while (style & win32con.WS_CHILDWINDOW) > 0:
                    parent = win32gui.GetParent(parent)
                    style = win32gui.GetWindowLong(parent, win32con.GWL_STYLE)
                result = parent

        return result
Beispiel #18
0
 def hide(self, new=True):
     """Hide a window from the task bar.
     Kept the old way just to be on the safe side.
     """
     if new:
         win32gui.ShowWindow(self.hwnd, False)
     else:
         self.minimise()
         win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE)
         win32gui.SetWindowLong(self.hwnd, win32con.GWL_EXSTYLE,
                                win32gui.GetWindowLong(self.hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_TOOLWINDOW)
         win32gui.ShowWindow(self.hwnd, win32con.SW_SHOW)
Beispiel #19
0
def make_borderless():
    """Remove the borders and titlebar from the game running in windowed mode.
    Todo: Windowed mode seems to cut off the bottom of the game. This is something that will need worked around."""
    hwnd = get_hwnd()
    style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
    style &= ~win32con.WS_CAPTION  # remove border and titlebar
    win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style)

    titlebar_height = win32gui.GetWindowRect(hwnd)[3] - win32gui.GetClientRect(hwnd)[3]
    # move the window up to compensate for the lack of a titlebar
    # the two flags result in the second, fifth and six arguments being ignored so we don't have to worry about them
    win32gui.SetWindowPos(hwnd, 0, 0, -titlebar_height, 0, 0, win32con.SWP_NOSIZE | win32con.SWP_NOZORDER)
Beispiel #20
0
 def set_visible(self, hwnd):
     try:
         # win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
         # win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_APPWINDOW);
         # win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE,
         #                        win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) & ~win32con.WS_EX_TOOLWINDOW);
         win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE,
                                win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) & ~win32con.WS_EX_LAYERED & ~win32con.WS_EX_TOOLWINDOW );
         # win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
         self.set_foreground(hwnd)
     except:
         print('fail: ' + str(sys.exc_info()[0]) + '(' + str(sys.exc_info()[1]) + ')')
Beispiel #21
0
 def _set_noactivate(self):
     hwnd = win32gui.GetActiveWindow()
     current_exstyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
     new_exstyle = (
         current_exstyle
         # | win32con.WS_EX_TOPMOST
         | win32con.WS_EX_TOOLWINDOW
         | win32con.WS_EX_NOACTIVATE
         | win32con.WS_EX_APPWINDOW)
     win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, new_exstyle)
     win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0,
                           win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
Beispiel #22
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)
Beispiel #23
0
 def is_real_from_hwnd(hwnd):
     if not win32gui.IsWindowVisible(hwnd):
         return False
     if win32gui.GetParent(hwnd):
         return False
     hasNoOwner = win32gui.GetWindow(hwnd, win32con.GW_OWNER) == 0
     lExStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
     if (((lExStyle & win32con.WS_EX_TOOLWINDOW) == 0 and hasNoOwner) or
         ((lExStyle & win32con.WS_EX_APPWINDOW != 0) and not hasNoOwner)):
         if win32gui.GetWindowText(hwnd):
             return True
     return False
Beispiel #24
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()  # 浏览器关闭后释放资源
Beispiel #25
0
 def _hide_w32_window(self):
     try:
         w32win = win32gui.FindWindow(None, self.title)
         win32gui.ShowWindow(w32win, SW_HIDE)
         win32gui.SetWindowLong(
             w32win, GWL_EXSTYLE,
             win32gui.GetWindowLong(w32win, GWL_EXSTYLE) | WS_EX_TOOLWINDOW)
         win32gui.ShowWindow(w32win, SW_SHOW)
         self._return_focus_w32()
     except Exception:
         tb = traceback.format_exc()
         Logger.error('Notification: An error occured in {}\n'
                      '{}'.format(self.title, tb))
Beispiel #26
0
 def makeItTransparent(
         self,
         alpha):  # Set alpha between 0 and 1. 0 no opacity, 1 invisible
     alpha = int((1 - alpha) * 255)
     win32gui.SetWindowLong(
         self.getHandleOfThisWindow(), win32con.GWL_EXSTYLE,
         win32gui.GetWindowLong(self.getHandleOfThisWindow(),
                                win32con.GWL_EXSTYLE)
         | win32con.WS_EX_LAYERED)  # Make it a layered window
     win32gui.SetLayeredWindowAttributes(
         self.getHandleOfThisWindow(), win32api.RGB(0, 0,
                                                    0), alpha, win32con.
         LWA_ALPHA)  # make it transparent (alpha between 0 and 255)
Beispiel #27
0
def isRealWindow(hWnd):
    '''Return True iff given window is a real Windows application window.'''
    if not win32gui.IsWindowVisible(hWnd):
        return False
    if win32gui.GetParent(hWnd) != 0:
        return False
    hasNoOwner = win32gui.GetWindow(hWnd, win32con.GW_OWNER) == 0
    lExStyle = win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE)
    if (((lExStyle & win32con.WS_EX_TOOLWINDOW) == 0 and hasNoOwner) or
        ((lExStyle & win32con.WS_EX_APPWINDOW != 0) and not hasNoOwner)):
        if win32gui.GetWindowText(hWnd):
            return True
    return False
Beispiel #28
0
    def onItemDoubleClicked(self, item):
        """列表双击选择事件"""
        # 先移除掉item
        self.windowList.takeItem(self.windowList.indexFromItem(item).row())
        hwnd, phwnd, _, _ = item.text().split('|')
        # 开始嵌入

        if self.layout().count() == 4:
            # 如果数量等于4说明之前已经嵌入了一个窗口,现在需要把它释放出来
            self.restore()
        hwnd, phwnd = int(hwnd), int(phwnd)
        # 嵌入之前的属性
        style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
        exstyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        print('save', hwnd, style, exstyle)

        widget = QWidget.createWindowContainer(QWindow.fromWinId(hwnd))
        widget.hwnd = hwnd  # 窗口句柄
        widget.phwnd = phwnd  # 父窗口句柄
        widget.style = style  # 窗口样式
        widget.exstyle = exstyle  # 窗口额外样式
        self.layout().addWidget(widget)
 def __init__(self, *args, **kwargs):
     super(Window, self).__init__(*args, **kwargs)
     self.resize(800, 600)
     self.setWindowFlags(Qt.Window
                         | Qt.FramelessWindowHint
                         | Qt.WindowSystemMenuHint
                         | Qt.WindowMinimizeButtonHint
                         | Qt.WindowMaximizeButtonHint
                         | Qt.WindowCloseButtonHint)
     # 增加薄边框
     style = win32gui.GetWindowLong(int(self.winId()), win32con.GWL_STYLE)
     win32gui.SetWindowLong(
         int(self.winId()), win32con.GWL_STYLE, style | win32con.WS_THICKFRAME)
Beispiel #30
0
 def isRealWindow(self, hWnd):
     '''Return True iff given handler corespond to a real visible window on the desktop.'''
     if not win32gui.IsWindowVisible(hWnd):
         return False
     if win32gui.GetParent(hWnd) != 0:
         return False
     hasNoOwner = win32gui.GetWindow(hWnd, win32con.GW_OWNER) == 0
     lExStyle = win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE)
     if (((lExStyle & win32con.WS_EX_TOOLWINDOW) == 0 and hasNoOwner) or
         ((lExStyle & win32con.WS_EX_APPWINDOW != 0) and not hasNoOwner)):
         if win32gui.GetWindowText(hWnd):
             return True
     return False