示例#1
0
    def run(self):
        """Fonction qui est appelé en boucle."""
        if sys.platform == 'win32':
            # Copie le DC de la source vers le DC de destination en le redimensionnant
            win32gui.StretchBlt(self.dest_window_dc, 0, 0,
                                self.dest_rect_dc[win32_RIGHT],
                                self.dest_rect_dc[win32_BOTTOM],
                                self.src_window_dc, 0, 0,
                                self.src_rect_dc[win32_RIGHT],
                                self.src_rect_dc[win32_BOTTOM], win.SRCCOPY)

            source_bitmap = win32gui.CreateCompatibleBitmap(
                self.dest_window_dc,
                self.dest_rect_dc[win32_RIGHT] - self.dest_rect_dc[win32_LEFT],
                self.dest_rect_dc[win32_BOTTOM] - self.dest_rect_dc[win32_TOP])

            if source_bitmap is None:
                log.add("Échec création bitmap.")
                return

            win32gui.SelectObject(self.mem_dc, source_bitmap)
            if self._hasToRun:
                # self._tkThread.after(250, self.run)
                pass
            else:
                log.add("Fin stream.")
        elif sys.platform == 'linux':
            """TODO : LIELA"""
            pass
示例#2
0
 def OnPaint(self, hwnd, msg, wp, lp):
     dc, ps = win32gui.BeginPaint(hwnd)
     wndrect = win32gui.GetClientRect(hwnd)
     wndwidth = wndrect[2] - wndrect[0]
     wndheight = wndrect[3] - wndrect[1]
     win32clipboard.OpenClipboard()
     try:
         try:
             hbitmap = win32clipboard.GetClipboardData(
                 win32clipboard.CF_BITMAP)
         except TypeError:
             font = win32gui.LOGFONT()
             font.lfHeight = 15  #int(wndheight/20)
             font.lfWidth = 15  #font.lfHeight
             #            font.lfWeight=150
             hf = win32gui.CreateFontIndirect(font)
             win32gui.SelectObject(dc, hf)
             win32gui.SetBkMode(dc, win32con.TRANSPARENT)
             win32gui.SetTextColor(dc, win32api.RGB(0, 0, 0))
             win32gui.DrawText(
                 dc,
                 'No bitmaps are in the clipboard\n(try pressing the PrtScn button)',
                 -1, (0, 0, wndwidth, wndheight), win32con.DT_CENTER)
         else:
             bminfo = win32gui.GetObject(hbitmap)
             dcDC = win32gui.CreateCompatibleDC(None)
             win32gui.SelectObject(dcDC, hbitmap)
             win32gui.StretchBlt(dc, 0, 0, wndwidth, wndheight, dcDC, 0, 0,
                                 bminfo.bmWidth, bminfo.bmHeight,
                                 win32con.SRCCOPY)
             win32gui.DeleteDC(dcDC)
             win32gui.EndPaint(hwnd, ps)
     finally:
         win32clipboard.CloseClipboard()
     return 0
示例#3
0
    def OnPaint(self, hWnd, msg, wparam, lparam):
        dc, ps = win32gui.BeginPaint(hWnd)
        wndrect = win32gui.GetClientRect(hWnd)
        wndwidth = wndrect[2] - wndrect[0]
        wndheight = wndrect[3] - wndrect[1]
        if os.path.isfile(FILENAME):
            hBitmap = win32gui.LoadImage(0, FILENAME, win32con.IMAGE_BITMAP, 0,
                                         0, win32con.LR_LOADFROMFILE)
            hdcBitmap = win32gui.CreateCompatibleDC(dc)
            hOldBitmap = win32gui.SelectObject(hdcBitmap, hBitmap)
            bminfo = win32gui.GetObject(hBitmap)
            win32gui.SetStretchBltMode(dc, win32con.COLORONCOLOR)
            win32gui.StretchBlt(dc, 0, 0, wndwidth, wndheight, hdcBitmap, 0, 0,
                                bminfo.bmWidth, bminfo.bmHeight,
                                win32con.SRCCOPY)
            win32gui.SelectObject(hdcBitmap, hOldBitmap)

        win32gui.EndPaint(hWnd, ps)
        return 0
示例#4
0
            def find_window(source_handle=0x00010100, dest_widget=self.tv):
                """Trouve la fenêtre spécifiée à l'aide de source_handle puis la copie sur le DC de dest_widget."""
                if isinstance(source_handle, str):
                    if source_handle != "" and source_handle != entry_hint:
                        source_handle = int(str(source_handle), 16)
                    else:
                        source_handle = None
                source_window_dc = win32gui.GetDC(source_handle)
                target_handle = dest_widget.winfo_id()
                target_window_dc = win32gui.GetDC(target_handle)

                mem_dc = win32gui.CreateCompatibleDC(target_window_dc)
                if mem_dc is None:
                    log.add("Échec de la création du compatibleDC.")
                    return

                dest_rect_dc = win32gui.GetClientRect(target_handle)
                print(dest_rect_dc)
                win32gui.SetStretchBltMode(target_window_dc, HALFTONE)

                # Copie le DC de la source vers le DC de destination en le redimensionnant
                win32gui.StretchBlt(target_window_dc, 0, 0,
                                    dest_rect_dc[const.win32_RIGHT],
                                    dest_rect_dc[const.win32_BOTTOM],
                                    source_window_dc, 0, 0,
                                    win32api.GetSystemMetrics(SM_CXSCREEN),
                                    win32api.GetSystemMetrics(SM_CYSCREEN),
                                    SRCCOPY)

                source_bitmap = win32gui.CreateCompatibleBitmap(
                    target_window_dc, dest_rect_dc[const.win32_RIGHT] -
                    dest_rect_dc[const.win32_LEFT],
                    dest_rect_dc[const.win32_BOTTOM] -
                    dest_rect_dc[const.win32_TOP])

                if source_bitmap is None:
                    log.add("Échec création bitmap.")
                    return

                win32gui.SelectObject(mem_dc, source_bitmap)
示例#5
0
                              win32con.DM_IN_BUFFER | win32con.DM_OUT_BUFFER)

pDC = win32gui.CreateDC(print_processor, pname, dm)
printerwidth = win32print.GetDeviceCaps(pDC, win32con.PHYSICALWIDTH)
printerheight = win32print.GetDeviceCaps(pDC, win32con.PHYSICALHEIGHT)

hwnd = win32gui.GetDesktopWindow()
l, t, r, b = win32gui.GetWindowRect(hwnd)
desktopheight = b - t
desktopwidth = r - l
dDC = win32gui.GetWindowDC(hwnd)

dcDC = win32gui.CreateCompatibleDC(dDC)
dcBM = win32gui.CreateCompatibleBitmap(dDC, desktopwidth, desktopheight)
win32gui.SelectObject(dcDC, dcBM)
win32gui.StretchBlt(dcDC, 0, 0, desktopwidth, desktopheight, dDC, 0, 0,
                    desktopwidth, desktopheight, win32con.SRCCOPY)

pcDC = win32gui.CreateCompatibleDC(pDC)
pcBM = win32gui.CreateCompatibleBitmap(pDC, printerwidth, printerheight)
win32gui.SelectObject(pcDC, pcBM)
win32gui.StretchBlt(pcDC, 0, 0, printerwidth, printerheight, dcDC, 0, 0,
                    desktopwidth, desktopheight, win32con.SRCCOPY)

win32print.StartDoc(pDC, ('desktop.bmp', None, None, 0))
win32print.StartPage(pDC)
win32gui.StretchBlt(pDC, 0, 0, int(printerwidth * .9), int(printerheight * .9),
                    pcDC, 0, 0, printerwidth, printerheight, win32con.SRCCOPY)

font = win32gui.LOGFONT()
font.lfHeight = int(printerheight / 20)
font.lfWidth = font.lfHeight
示例#6
0
def tennel(times):
    win32gui.StretchBlt(t, 50, 50, w - 100, h - 100, t, 0, 0, w, h, SRCCOPY)
    time.sleep(times)
示例#7
0

try:
    music = mp3play.load('Running_In_The_90s.mp3')
    music.play()
except:
    pass
#------------
drawerror(12.5)
inversecolor()
for i in range(12):
    if i == 6: inversecolor()
    drawtext(.5)
inversecolor()
for i in [1.3, 1, .6, .4, .4, .4, .4, .3, .3]:
    tennel(i)
#------------
i = 1
while True:
    x, y = random.randint(0, w), random.randint(0, h)
    if (i + 1) % 100 == 0:
        win32gui.DrawIcon(t, x, y, win32gui.LoadIcon(None, random.choice(s)))
    pi = math.pi
    parts = pi / 10000
    lens = 15
    px, py = map(int, [math.cos(parts * i) * lens, math.sin(parts * i) * lens])
    if (i + 1) % 100 == 0:
        win32gui.StretchBlt(t, 30 + px, 30 + py, w - 60 + px, h - 60 + py, t,
                            0, 0, w, h, SRCCOPY)
    i += 1