示例#1
0
    def _create_main_window(self):
        # Set window style
        style = win32con.WS_VISIBLE | win32con.WS_OVERLAPPEDWINDOW
        if not self.resizable:
            style = style ^ win32con.WS_THICKFRAME

        #  Center window on the screen
        screen_x = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
        screen_y = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
        self.pos_x = int((screen_x - self.width) / 2)
        self.pos_y = int((screen_y - self.height) / 2)

        # Create Window
        self.hwnd = win32gui.CreateWindow(self.wndclass.lpszClassName,
                                          self.title, style, self.pos_x, self.pos_y, self.width, self.height,
                                          None, None, self.wndclass.hInstance, None)

        # Set fullscreen
        if self.fullscreen:
            self.width = screen_x
            self.height = screen_y

            style = win32gui.GetWindowLong(self.hwnd, win32con.GWL_STYLE)
            win32gui.SetWindowLong(self.hwnd, win32con.GWL_STYLE, style & ~(win32con.WS_CAPTION | win32con.WS_THICKFRAME))

            win32gui.SetWindowLong(self.hwnd, win32con.GWL_EXSTYLE, style &
                                   ~(win32con.WS_EX_DLGMODALFRAME | win32con.WS_EX_WINDOWEDGE |
                                     win32con.WS_EX_CLIENTEDGE | win32con.WS_EX_STATICEDGE))

            win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOP, 0, 0, screen_x, screen_y,
                                  win32con.SWP_NOOWNERZORDER | win32con.SWP_FRAMECHANGED | win32con.SWP_NOZORDER | win32con.SWP_NOACTIVATE)
        else:
            win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOP, self.pos_x, self.pos_y, self.width, self.height,
                                  win32con.SWP_SHOWWINDOW)
示例#2
0
def enumHandler(mcWin, ctx):
    title = win32gui.GetWindowText(mcWin)
    if title.startswith('Minecraft') and (title[-1].isdigit()
                                          or title.endswith('Singleplayer') or
                                          title.endswith('Multiplayer (LAN)')):
        style = win32gui.GetWindowLong(mcWin, -16)
        if style == 369623040:
            if fsMode.get() == 2:
                rect = win32gui.GetWindowRect(mcWin)
                if rect[3] == 1080:
                    win32gui.SetWindowPos(mcWin, win32con.HWND_TOP, 0, 0, 1920,
                                          1027, 0x0004)
                    return False
                else:
                    win32gui.SetWindowPos(mcWin, win32con.HWND_TOP, 0, 0, 1920,
                                          1080, 0x0004)
                    return False
            style = 382664704
            win32gui.SetWindowLong(mcWin, win32con.GWL_STYLE, style)
            if fsMode.get() == 3:
                win32gui.SetWindowPos(mcWin, win32con.HWND_TOP, 650, 0, 700,
                                      1050, 0x0004)
            elif fsMode.get() == 1:
                win32gui.SetWindowPos(mcWin, win32con.HWND_TOP, 0, 320, 1920,
                                      400, 0x0004)
            else:
                win32gui.SetWindowPos(mcWin, win32con.HWND_TOP, 530, 250, 900,
                                      550, 0x0004)
        else:
            style &= ~(0x00800000 | 0x00400000 | 0x00040000 | 0x00020000
                       | 0x00010000 | 0x00800000)
            win32gui.SetWindowLong(mcWin, win32con.GWL_STYLE, style)
            win32gui.SetWindowPos(mcWin, win32con.HWND_TOP, 0, 0, 1920, 1080,
                                  0x0004)
        return False
示例#3
0
	def do2(root):
		hwnd=int(root.wm_frame(),0)
		style=win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)	#remove style from bar
		style &=  ~win32con.WS_EX_APPWINDOW
		print(style)
		win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, style)
		style = win32gui.GetWindowLong(hwnd,  win32con.GWL_EXSTYLE)	#add correct style
		style |= win32con.WS_EX_TOOLWINDOW
		win32gui.SetWindowLong(hwnd,win32con.GWL_EXSTYLE, style)
示例#4
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()  # 浏览器关闭后释放资源
示例#5
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()
示例#6
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)
示例#7
0
    def __init__(self, parent=None, point_size=23, *args, **kw):
        super().__init__(parent,
                         style=wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP
                         | wx.BORDER_NONE | wx.CLIP_CHILDREN,
                         *args,
                         **kw)

        # let the frame can be clicked through, which means it won't block mouse events
        # http://wxwidgets.10942.n7.nabble.com/wxPython-and-pywin32-Implementing-on-top-transparency-and-click-through-on-Windows-tp30543.html
        hwnd = self.GetHandle()
        extended_style_settings = win32gui.GetWindowLong(
            hwnd, win32con.GWL_EXSTYLE)
        win32gui.SetWindowLong(
            hwnd, win32con.GWL_EXSTYLE, extended_style_settings
            | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT)
        win32gui.SetLayeredWindowAttributes(hwnd, 0, 255, win32con.LWA_ALPHA)

        # prevent text flickering
        self.SetDoubleBuffered(True)

        self.SetTransparent(200)
        self.SetBackgroundColour('black')

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        self.text = wx.StaticText(self)
        self.text.SetForegroundColour('white')

        font = self.text.GetFont()
        font.PointSize = point_size
        self.text.SetFont(font)

        sizer.Add(self.text, 0, wx.LEFT | wx.RIGHT, border=5)
示例#8
0
 def setNoTitleWindow(hwnd):
     ISTYLE = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
     win32gui.SetWindowLong(hwnd,
                            ISTYLE &
                            ~win32con.WS_CAPTION &
                            win32con.SWP_NOMOVE &
                            win32con.SWP_NOSIZE)
示例#9
0
    def undecorate(self):
        """
        Removes borders and decoration from window
        Returns True on success
        Returns False on error
        """

        try:

            if not self.decorated:

                style = win32gui.GetWindowLong(self.hWindow, GWL_STYLE)

                style -= WS_CAPTION 

                win32gui.SetWindowLong(self.hWindow, GWL_STYLE, style)

                return True

            return False

        except win32gui.error:

            logging.exception("Error while undecorating the window")

            return False
示例#10
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
示例#11
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          title="Clipboard viewer",
                          size=(250, 150))

        self.first = True
        self.nextWnd = None

        # Get native window handle of this wxWidget Frame.
        self.hwnd = self.GetHandle()

        # Set the WndProc to our function.
        self.oldWndProc = win32gui.SetWindowLong(self.hwnd,
                                                 win32con.GWL_WNDPROC,
                                                 self.MyWndProc)

        try:
            self.nextWnd = win32clipboard.SetClipboardViewer(self.hwnd)
        except win32api.error:
            if win32api.GetLastError() == 0:
                # information that there is no other window in chain
                pass
            else:
                raise
示例#12
0
def TestGradientFill():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = "test_win32gui_2"
    wc.style = win32con.CS_GLOBALCLASS | win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW + 1
    wc.lpfnWndProc = wndproc_2
    class_atom = win32gui.RegisterClass(wc)
    hwnd = win32gui.CreateWindowEx(
        0,
        class_atom,
        "Kaleidoscope",
        win32con.WS_CAPTION
        | win32con.WS_VISIBLE
        | win32con.WS_THICKFRAME
        | win32con.WS_SYSMENU,
        100,
        100,
        900,
        900,
        0,
        0,
        0,
        None,
    )
    s = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE,
                           s | win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA)
    for x in range(30):
        win32gui.InvalidateRect(hwnd, None, True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.3)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(class_atom, None)
示例#13
0
    def set_clickthrough(self):
        """
        Allow for making mouse clicks pass through the window, in case you want to use it as an overlay in your game
        Also makes the window transparent to visualize this effect.
        Calling the function again reverts the window to normal state.
        """
        hwnd = win32gui.FindWindow(None, self.title)
        if self.clickable:
            # Get window style and perform a 'bitwise or' operation to make the style layered and transparent, achieving
            # the clickthrough property
            l_ex_style = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
            l_ex_style |= win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED
            win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, l_ex_style)

            # Set the window to be transparent and appear always on top
            win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(0, 0, 0), 190, win32con.LWA_ALPHA)  # transparent
            win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, self.root.winfo_x(), self.root.winfo_y(), 0, 0, 0)
            self.clickable = False
        else:
            # Calling the function again sets the extended style of the window to zero, reverting to a standard window
            win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, 0)
            if not self.always_on_top:
                # Remove the always on top property again, in case always on top was set to false in options
                win32gui.SetWindowPos(hwnd, win32con.HWND_NOTOPMOST, self.root.winfo_x(), self.root.winfo_y(), 0, 0, 0)
            self.clickable = True
示例#14
0
 def set_transparent(self, hwnd, alpha):
     # win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32con.WS_POPUP)
     print('p1o13p')
     # win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, (win32gui.GetWindowLong(
     #     hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED) & (~(win32con.WS_CAPTION
     #                                                                | win32con.WS_THICKFRAME
     #                                                                | win32con.WS_MINIMIZEBOX
     #                                                                | win32con.WS_MAXIMIZEBOX
     #                                                                | win32con.WS_SYSMENU
     #                                                                | win32con.WS_BORDER
     #                                                                | win32con.WS_DLGFRAME
     #                                                                )))
     win32gui.SetWindowLong(
         hwnd, win32con.GWL_EXSTYLE,
         win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
         | win32con.WS_EX_LAYERED)
     # win32con.WS_BORDER)
     win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(95, 95, 95),
                                         int(alpha * 255),
                                         win32con.LWA_ALPHA)
     # SetWindowPos(hwnd, NULL, 0,0,0,0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
     # SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER
     # win32gui.SetWindowPos(hwnd, 0, 0, 0, 480, 640, win32con.SWP_NOMOVE |
     #                       win32con.SWP_NOSIZE | win32con.SWP_NOOWNERZORDER |
     # win32con.SWP_NOZORDER | win32con.SWP_FRAMECHANGED)
     pass
示例#15
0
 def detect_win32_session_events(self, app_hwnd):
     """
     Use pywin32 to receive session notification events.
     """
     if app_hwnd is None:
         if self.tray_widget is None:
             #probably closing down, don't warn
             return
         log.warn("detect_win32_session_events(%s) missing handle!",
                  app_hwnd)
         return
     try:
         debug("detect_win32_session_events(%s)", app_hwnd)
         #register our interest in those events:
         #http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html#isenslogon
         #http://stackoverflow.com/questions/365058/detect-windows-logout-in-python
         #http://msdn.microsoft.com/en-us/library/aa383841.aspx
         #http://msdn.microsoft.com/en-us/library/aa383828.aspx
         win32ts.WTSRegisterSessionNotification(
             app_hwnd, win32ts.NOTIFY_FOR_THIS_SESSION)
         #catch all events: http://wiki.wxpython.org/HookingTheWndProc
         self.old_win32_proc = win32gui.SetWindowLong(
             app_hwnd, win32con.GWL_WNDPROC, self.MyWndProc)
     except Exception, e:
         log.error("failed to hook session notifications: %s", e)
def OnPaint_1(hwnd, msg, wp, lp):
    dc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    br = win32gui.CreateSolidBrush(win32api.RGB(255, 0, 0))
    win32gui.SelectObject(dc, br)
    angle = win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA)
    win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle + 2)
    r_angle = angle * (math.pi / 180)
    win32gui.SetWorldTransform(
        dc, {
            'M11': math.cos(r_angle),
            'M12': math.sin(r_angle),
            'M21': math.sin(r_angle) * -1,
            'M22': math.cos(r_angle),
            'Dx': 250,
            'Dy': 250
        })
    win32gui.MoveToEx(dc, 250, 250)
    win32gui.BeginPath(dc)
    win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10)
    win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10)
    win32gui.LineTo(dc, 300, 300)
    win32gui.LineTo(dc, 100, 20)
    win32gui.LineTo(dc, 20, 100)
    win32gui.LineTo(dc, 400, 0)
    win32gui.LineTo(dc, 0, 400)
    win32gui.EndPath(dc)
    win32gui.StrokeAndFillPath(dc)
    win32gui.EndPaint(hwnd, ps)
    return 0
示例#17
0
    def mycreateoverlay(self):
        try:
            if self.overlaywindow.state() == "normal":
                self.overlaywindow.focus()
        except:
            self.overlaywindow = Toplevel(self.mainwindow)
            self.overlaywindow.attributes("-fullscreen", True)
            self.overlaywindow.attributes("-transparentcolor", "red")
            self.overlaywindow.update_idletasks()
            self.overlaywindow.lift()
            self.overlayframe = Frame(self.overlaywindow,
                                      bg="red",
                                      borderwidth=10,
                                      highlightthickness=0)

            self.overlayframe.pack(anchor=CENTER,
                                   ipady=self.mainwindow.winfo_screenheight(),
                                   ipadx=self.mainwindow.winfo_screenwidth())
            l = Label(self.overlayframe, textvariable=foldername)
            l.pack(anchor=NW)
            hwnd = l.winfo_id()
            lExStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
            lExStyle |= win32con.WS_EX_LAYERED
            win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, lExStyle)
            win32gui.SetLayeredWindowAttributes(hwnd, 0, 255,
                                                win32con.LWA_ALPHA)
            self.mylist()
            self.overlaywindow.wm_attributes("-topmost", True)
            self.overlaywindow.overrideredirect(1)
示例#18
0
def make_window_borderless(hwnd):	
	style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
	style &= ~win32con.WS_OVERLAPPEDWINDOW
	style |= win32con.WS_POPUP
	win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style)
	win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
	win32gui.ShowWindow(hwnd, win32con.SW_RESTORE)
示例#19
0
def terminate():
    clock = pygame.time.Clock()

    pygame.mixer.music.load("resources/final_message.mp3")
    pygame.mixer.music.play()

    while pygame.mixer.music.get_busy():
        clock.tick(30)

    pygame.mixer.music.load("resources/ending.mp3")
    pygame.mixer.music.play()

    # Create layered window
    hwnd = pygame.display.get_wm_info()["window"]
    win32gui.SetWindowLong(
        hwnd, win32con.GWL_EXSTYLE,
        win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        | win32con.WS_EX_LAYERED)

    clock = pygame.time.Clock()
    i = 255
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pass
        win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(0, 0, 0),
                                            round(i), win32con.LWA_ALPHA)
        i = max(0, i - 1.5)
        if i == 0:
            break
        clock.tick(30)
        pygame.display.update()

    pygame.quit()
    sys.exit(0)
示例#20
0
    def detect_win32_session_events(self, app_hwnd):
        """
		Use pywin32 to receive session notification events.
		"""
        log.debug("detect_win32_session_events(%s)" % app_hwnd)
        try:
            import win32ts, win32con, win32api, win32gui  #@UnresolvedImport
            WM_TRAYICON = win32con.WM_USER + 20
            NIN_BALLOONSHOW = win32con.WM_USER + 2
            NIN_BALLOONHIDE = win32con.WM_USER + 3
            NIN_BALLOONTIMEOUT = win32con.WM_USER + 4
            NIN_BALLOONUSERCLICK = win32con.WM_USER + 5
            #register our interest in those events:
            #http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html#isenslogon
            #http://stackoverflow.com/questions/365058/detect-windows-logout-in-python
            #http://msdn.microsoft.com/en-us/library/aa383841.aspx
            #http://msdn.microsoft.com/en-us/library/aa383828.aspx
            win32ts.WTSRegisterSessionNotification(
                app_hwnd, win32ts.NOTIFY_FOR_THIS_SESSION)

            #catch all events: http://wiki.wxpython.org/HookingTheWndProc
            def MyWndProc(hWnd, msg, wParam, lParam):
                #from the web!: WM_WTSSESSION_CHANGE is 0x02b1.
                if msg == 0x02b1:
                    log.debug("Session state change!")
                elif msg == win32con.WM_DESTROY:
                    # Restore the old WndProc
                    log.debug("WM_DESTROY, restoring call handler")
                    win32api.SetWindowLong(app_hwnd, win32con.GWL_WNDPROC,
                                           self.oldWndProc)
                elif msg == win32con.WM_COMMAND:
                    log.debug("WM_COMMAND")
                elif msg == WM_TRAYICON:
                    log.debug("WM_TRAYICON")
                    if lParam == NIN_BALLOONSHOW:
                        log.debug("NIN_BALLOONSHOW")
                    if lParam == NIN_BALLOONHIDE:
                        log.debug("NIN_BALLOONHIDE")
                        self.balloon_click_callback = None
                    elif lParam == NIN_BALLOONTIMEOUT:
                        log.debug("NIN_BALLOONTIMEOUT")
                    elif lParam == NIN_BALLOONUSERCLICK:
                        log.info(
                            "NIN_BALLOONUSERCLICK, balloon_click_callback=%s" %
                            self.balloon_click_callback)
                        if self.balloon_click_callback:
                            self.balloon_click_callback()
                            self.balloon_click_callback = None
                else:
                    log.debug("unknown win32 message: %s / %s / %s", msg,
                              wParam, lParam)
                # Pass all messages to the original WndProc
                try:
                    return win32gui.CallWindowProc(self.old_win32_proc, hWnd,
                                                   msg, wParam, lParam)
                except Exception, e:
                    log.error("error delegating call: %s", e)

            self.old_win32_proc = win32gui.SetWindowLong(
                app_hwnd, win32con.GWL_WNDPROC, MyWndProc)
示例#21
0
文件: base.py 项目: TeamSWAP/swap
 def setClickThrough(self, clickThrough):
     style = win32gui.GetWindowLong(self.hwnd, GWL_EXSTYLE)
     if clickThrough:
         style |= WS_EX_TRANSPARENT
     else:
         style &= ~WS_EX_TRANSPARENT
     win32gui.SetWindowLong(self.hwnd, GWL_EXSTYLE, style)
示例#22
0
    def _CreateMainWindow(self, prev, settings, browser, rect):
        # Creates a parent window that hosts the view window.  This window
        # gets the control notifications etc sent from the child.
        style = win32con.WS_CHILD | win32con.WS_VISIBLE  #
        wclass_name = "ShellViewDemo_DefView"
        # Register the Window class.
        wc = win32gui.WNDCLASS()
        wc.hInstance = win32gui.dllhandle
        wc.lpszClassName = wclass_name
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        try:
            win32gui.RegisterClass(wc)
        except win32gui.error as details:
            # Should only happen when this module is reloaded
            if details[0] != winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise

        message_map = {
            win32con.WM_DESTROY: self.OnDestroy,
            win32con.WM_COMMAND: self.OnCommand,
            win32con.WM_NOTIFY: self.OnNotify,
            win32con.WM_CONTEXTMENU: self.OnContextMenu,
            win32con.WM_SIZE: self.OnSize,
        }

        self.hwnd = win32gui.CreateWindow(wclass_name, "", style, \
                                          rect[0], rect[1], rect[2] - rect[0], rect[3] - rect[1],
                                          self.hwnd_parent, 0, win32gui.dllhandle, None)
        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)
        print("View 's hwnd is", self.hwnd)
        return self.hwnd
示例#23
0
def assign_window_color_for_transparency(hwnd, color_tuple):
    win32gui.SetWindowLong(
        hwnd, win32con.GWL_EXSTYLE,
        win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        | win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(*color_tuple), 0,
                                        win32con.LWA_COLORKEY)
示例#24
0
文件: base.py 项目: TeamSWAP/swap
 def setFocusable(self, isFocusable):
     style = win32gui.GetWindowLong(self.hwnd, GWL_EXSTYLE)
     if isFocusable:
         style &= ~WS_EX_NOACTIVATE
     else:
         style |= WS_EX_NOACTIVATE
     win32gui.SetWindowLong(self.hwnd, GWL_EXSTYLE, style)
示例#25
0
    def hide_extra_ui(self, hwnd=None, remove=True):
        """
        :param hwnd: Hwnd to remove all styling from. If not supplied, then the default hwnd is used
        :param remove: If true: Removes all styling. If false: Adds back the removed styles
        :return: NoneType
        """

        logging.debug('Trying to manipulate UI')

        if hwnd is None:
            hwnd = self.get_hwnd()

        style = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)

        if remove:
            logging.debug('Removing UI')
            style = style | win32con.WS_POPUP
            style = style & ~win32con.WS_OVERLAPPEDWINDOW
        else:
            logging.debug('Adding UI')
            style = style & ~win32con.WS_POPUP
            style = style | win32con.WS_OVERLAPPEDWINDOW

        win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
        win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style)
        win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
示例#26
0
def fixup_window_style(self, *args):
    """ a fixup function we want to call from other places """
    hwnd = get_window_handle(self)
    if not hwnd:
        return
    try:
        #warning: accessing "_metadata" on the client window class is fugly..
        metadata = getattr(self, "_metadata", {})
        if metadata.get("modal", False):
            #window is not / no longer meant to be decorated
            #(this is what GTK does for modal windows - keep it consistent)
            return
        cur_style = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE)
        #re-add taskbar menu:
        style = cur_style
        if cur_style & win32con.WS_CAPTION:
            style |= win32con.WS_SYSMENU
            style |= win32con.WS_MAXIMIZEBOX
            style |= win32con.WS_MINIMIZEBOX
            if style != cur_style:
                log(
                    "fixup_window_style() using %s (%#x) instead of %s (%#x) on window %#x with metadata=%s",
                    style_str(style), style, style_str(cur_style), cur_style,
                    hwnd, metadata)
                win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style)
            else:
                log(
                    "fixup_window_style() unchanged style %s (%#x) on window %#x",
                    style_str(style), style, hwnd)
    except:
        log.warn("failed to fixup window style", exc_info=True)
示例#27
0
def imageBouncer():
    global WIN_WIDTH, WIN_HEIGHT

    img = getImage()

    clock = pygame.time.Clock()
    dt = clock.tick(60)

    screen = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT), pygame.RESIZABLE)
    pygame.display.set_caption('Image Bouncer')
    pygame.display.set_icon(pygame.image.load('res/icon.png'))

    # Set window transparency color
    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(*BLACK), 0,
                                        win32con.LWA_COLORKEY)

    done = False
    while not done:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True
            if event.type == pygame.VIDEORESIZE:
                WIN_WIDTH = event.w
                WIN_HEIGHT = event.h
                screen = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT),
                                                 pygame.RESIZABLE)

        screen.fill(BLACK)  # Set transparent background

        if img.x + img.w >= WIN_WIDTH:
            img.x_vel = -INIT_VEL
            img.x = WIN_WIDTH - img.w
        elif img.x <= 0:
            img.x_vel = INIT_VEL
            img.x = 0

        if img.y + img.h >= WIN_HEIGHT:
            img.y_vel = -INIT_VEL
            img.y = WIN_HEIGHT - img.h
        elif img.y <= 0:
            img.y_vel = INIT_VEL
            img.y = 0

        if dt < 100:
            img.x += img.x_vel * dt
            img.y += img.y_vel * dt

        screen.blit(img.img, (int(img.x), int(img.y)))

        pygame.display.update()

        dt = clock.tick(60)

    pygame.display.quit()
示例#28
0
def create_hidden_window():
    window_handler = win32gui.CreateWindow("EDIT", "Integrator window hook", 0,
                                           0, 0, 0, 0, 0, 0, 0, None)
    if not window_handler:
        raise Exception("Cannot create hidded window!")
    win32gui.SetWindowLong(window_handler, win32con.GWL_WNDPROC,
                           message_handler)
    return window_handler
示例#29
0
 def set_transparency(self):
     existing_bits = win32gui.GetWindowLong(self.shell_hwnd,
                                            win32con.GWL_EXSTYLE)
     win32gui.SetWindowLong(self.shell_hwnd, win32con.GWL_EXSTYLE,
                            existing_bits | win32con.WS_EX_LAYERED)
     win32gui.SetLayeredWindowAttributes(
         self.shell_hwnd, 1, int(self.transparent_factor * 255),
         win32con.LWA_COLORKEY | win32con.LWA_ALPHA)
示例#30
0
def overlay_cv_window(hwnd, alpha=100):
    try:
        styles = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        styles = win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT
        win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, styles)
        win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(0,0,0), alpha, win32con.LWA_COLORKEY)
    except Exception as e:
        print(e)