Ejemplo n.º 1
0
def wndProc(hWnd, message, wParam, lParam):
    if message == win32con.WM_PAINT:
        hdc, paintStruct = win32gui.BeginPaint(hWnd)
        dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0
        fontSize = 18
        lf = win32gui.LOGFONT()
        lf.lfFaceName = "Comic Sans"
        lf.lfHeight = int(round(dpiScale * fontSize))
        hf = win32gui.CreateFontIndirect(lf)
        win32gui.SelectObject(hdc, hf)
        rect = win32gui.GetClientRect(hWnd)
        win32gui.DrawText(
            hdc, windowText, -1, rect,
            win32con.DT_LEFT | win32con.DT_BOTTOM | win32con.DT_SINGLELINE)
        win32gui.EndPaint(hWnd, paintStruct)
        return 0

    elif message == win32con.WM_DESTROY:
        print('Being destroyed')
        win32gui.PostQuitMessage(0)
        return 0

    else:
        return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
        calrect = win32gui.DrawText(hdc, text, -1, rect,
                                    textformat | win32con.DT_CALCRECT)

        rect.top = rect.bottom - calcrect.bottom
        win32gui.DrawText(hDC, text, -1, rect, textformat)
Ejemplo n.º 2
0
def renderOverlayText(text, region, color):
    win32gui.SetTextColor(hdc)
    win32gui.DrawText(
        hdc, text, -1, (rect[0] + 1, rect[1] + 1, rect[2] + 1, rect[3] + 1),
        win32con.DT_CENTER | win32con.DT_NOCLIP | win32con.DT_SINGLELINE
        | win32con.DT_VCENTER)
    win32gui.DrawText(
        hdc, text, -1, rect, win32con.DT_CENTER | win32con.DT_NOCLIP
        | win32con.DT_SINGLELINE | win32con.DT_VCENTER)
Ejemplo n.º 3
0
def wndProc(hWnd, message, wParam, lParam):
    global data

    if message == win32con.WM_PAINT:
        hdc, paintStruct = win32gui.BeginPaint(hWnd)

        dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0
        fontSize = 80

        # http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
        lf = win32gui.LOGFONT()
        lf.lfFaceName = "Times New Roman"
        lf.lfHeight = int(round(dpiScale * fontSize))
        #lf.lfWeight = 150
        # Use nonantialiased to remove the white edges around the text.
        # lf.lfQuality = win32con.NONANTIALIASED_QUALITY
        hf = win32gui.CreateFontIndirect(lf)
        win32gui.SelectObject(hdc, hf)

        rect = win32gui.GetClientRect(hWnd)
        # http://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx
        if not loaded:
            win32gui.DrawText(
                hdc, 'Loading Neural Net...', -1, rect,
                win32con.DT_CENTER | win32con.DT_NOCLIP
                | win32con.DT_SINGLELINE | win32con.DT_VCENTER)

        color = win32api.RGB(0, 0, 255)
        color2 = win32api.RGB(255, 255, 0)
        brush = win32gui.CreateSolidBrush(color)
        fontSize = 12
        lf = win32gui.LOGFONT()
        lf.lfFaceName = 'Times New Roman'
        lf.lfHeight = int(round(dpiScale * fontSize))
        lf.lfQuality = win32con.NONANTIALIASED_QUALITY
        hf = win32gui.CreateFontIndirect(lf)
        win32gui.SelectObject(hdc, hf)
        win32gui.SetTextColor(hdc, color2)

        for minion in data:
            win32gui.DrawText(
                hdc, minion['class'] + ' ' + str(int(minion['score'] * 100)),
                -1, minion['location'], win32con.DT_BOTTOM
                | win32con.DT_SINGLELINE | win32con.DT_NOCLIP)
            win32gui.FrameRect(hdc, minion['location'], brush)

        win32gui.EndPaint(hWnd, paintStruct)
        return 0

    elif message == win32con.WM_DESTROY:
        print('Closing the window.')
        win32gui.PostQuitMessage(0)
        return 0

    else:
        return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
Ejemplo n.º 4
0
def OnPaint(hwnd, msg, wp, lp):
    global dx
    font = win32gui.LOGFONT()
    font.lfFaceName = "Consolas"
    font.lfHeight = 48
    # font.lfWidth=font.lfHeight
    # font.lfWeight=150
    # font.lfItalic=1
    # font.lfUnderline=1
    hfont = win32gui.CreateFontIndirect(font)
    dc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    l, t, r, b = win32gui.GetClientRect(hwnd)
    br = win32gui.CreateSolidBrush(win32api.RGB(0, 0, 255))
    bitmap = win32gui.CreateBitmap(20, 5, 4, 1, None)
    win32gui.SelectObject(dc, bitmap)
    win32gui.SelectObject(dc, br)
    win32gui.SelectObject(dc, hfont)
    win32gui.SetTextColor(
        dc, win32api.RGB(randint(1, 255), randint(1, 255), randint(1, 255)))
    win32gui.DrawText(dc, 'hello', -1, (100, 100, 300, 300), 0)
    win32gui.FillRect(dc, (200 + dx, 200 + dx, 100 + dx, 100 + dx), br)
    dx = (dx + 10) % 100
    win32gui.EndPaint(hwnd, ps)
    return 0
 def BGWndProc(self,hwnd,msg,wParam,lParam):
     if msg == win32con.WM_PAINT:
         #print('BG painting...%d...'%wParam)
         hdc,ps = win32gui.BeginPaint(hwnd)
         rect = win32gui.GetClientRect(hwnd)
 #        win32gui.Rectangle(hdc,min(xc),min(yc),max(xc),max(yc))
 #        win32gui.Ellipse(hdc,300+wParam,550,400+wParam,650)
         DFW.OnChange(mode='RandomMove')
         
         #self.hdcbuffer = win32gui.CreateCompatibleDC(hdc)
         #hBitMap = win32gui.CreateCompatibleBitmap(hdc, 1920, 1080)
         ###win32gui.ReleaseDC(hwnd, hdc)
         #win32gui.SelectObject(self.hdcbuffer, hBitMap)
         #win32gui.PatBlt(self.hdcbuffer, 0, 0, 1920, 1080, win32con.WHITENESS)
         
         #win32gui.SetBkMode(hdc,win32con.TRANSPARENT)
         for index in range(len(DFW.Words)):
             rect = (int(DFW.Coors[index][0]),int(DFW.Coors[index][1]),1920,1080)
             win32gui.DrawText(hdc,'%s,%d'%(DFW.Words[index],wParam),
                 len('%s'%(DFW.Words[index])),rect,win32con.DT_SINGLELINE|win32con.DT_TOP|win32con.DT_LEFT)
         #win32gui.BitBlt(hdc, 0, 0, 1920, 1080, self.hdcbuffer, 0, 0, win32con.SRCCOPY )
         win32gui.EndPaint(hwnd,ps)
     elif msg == win32con.WM_DESTROY:  
         win32gui.PostQuitMessage(0)
     elif msg == win32con.WM_TIMER:
         #print("BG TIMER TRIGGERED",wParam)
         win32gui.InvalidateRect(hwnd,None,True)
         win32gui.UpdateWindow(hwnd)
     else:
         pass
         #print('BG:其他信息:',msg)
     return win32gui.DefWindowProc(hwnd,msg,wParam,lParam)  
Ejemplo n.º 6
0
def WndProc(hwnd, msg, wParam, lParam):
    """
    视窗处理
    :param hwnd: 句柄
    :param msg: 消息
    :param wParam: 参数1
    :param lParam: 参数2
    :return: 下一个消息处理器
    """

    if msg == WM_PAINT:
        hdc, ps = win32gui.BeginPaint(hwnd)
        rect = win32gui.GetClientRect(hwnd)
        _str = u'请把【项目经理:日报】文件拖拽到这!'
        win32gui.DrawText(hdc, _str,
                          len(_str) * 2 - 4, rect,
                          DT_SINGLELINE | DT_CENTER | DT_VCENTER)
        win32gui.EndPaint(hwnd, ps)
        win32gui.DragAcceptFiles(hwnd, 1)
    elif msg == WM_DESTROY:
        win32gui.PostQuitMessage(0)
    elif msg == WM_DROPFILES:
        """文件拖拉消息
        """
        hDropInfo = wParam
        filescount = win32api.DragQueryFile(hDropInfo)
        for i in range(filescount):
            """获取文件名"""
            filename = win32api.DragQueryFile(hDropInfo, i)
            """处理文件"""
            fileHandler(hwnd, filename)
        win32api.DragFinish(hDropInfo)

    return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 7
0
 def wndProc(self, hwnd, msg, wParam, lParam):
     """
     消息处理
     :param hwnd:
     :param msg:
     :param wParam:
     :param lParam:
     :return:
     """
     if msg == win32con.WM_PAINT:
         hdc, ps = win32gui.BeginPaint(hwnd)
         rect = win32gui.GetClientRect(hwnd)
         win32gui.DrawText(
             hdc, 'GUI Python', len('GUI Python'), rect,
             win32con.DT_SINGLELINE | win32con.DT_CENTER
             | win32con.DT_VCENTER)
         win32gui.EndPaint(hwnd, ps)
     if msg == win32con.WM_CREATE:
         print('message: WM_CREATE')
     if msg == win32con.WM_SIZE:
         print('message: WM_SIZE')
     if msg == win32con.WM_PAINT:
         print('message: WM_PAINT')
     if msg == 1280:
         print("message: 1280")
     if msg == win32con.WM_CLOSE:
         print('message: WM_CLOSE')
     if msg == win32con.WM_DESTROY:
         print('message: WM_DESTROY')
         win32gui.PostQuitMessage(0)
     return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 8
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
Ejemplo n.º 9
0
def WndProc(hwnd, msg, wParam, lParam):

    if msg == WM_PAINT:
        hdc, ps = win32gui.BeginPaint(hwnd)
        rect = win32gui.GetClientRect(hwnd)
        _str = u'请把【星任务】文件拖拽到这!'
        win32gui.DrawText(hdc, _str,
                          len(_str) * 2, rect,
                          DT_SINGLELINE | DT_CENTER | DT_VCENTER)
        win32gui.EndPaint(hwnd, ps)
        win32gui.DragAcceptFiles(hwnd, 1)
    elif msg == WM_DESTROY:
        win32gui.PostQuitMessage(0)
    elif msg == WM_DROPFILES:
        hDropInfo = wParam
        filescount = win32api.DragQueryFile(hDropInfo)
        for i in range(filescount):
            filename = win32api.DragQueryFile(hDropInfo, i)
            if os.path.isdir(filename):
                _files = scan_files(filename)
            else:
                _files = [filename]

            if len(_files) > 0:
                for _f in _files:
                    fileHandler(_f)
        win32api.DragFinish(hDropInfo)

    return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 10
0
def WndProc(hwnd, msg, wParam, lParam):

    if msg == WM_PAINT:
        hdc, ps = win32gui.BeginPaint(hwnd)
        rect = win32gui.GetClientRect(hwnd)
        _str = u'请把【工作日志】目录拖拽到这!'
        win32gui.DrawText(hdc, _str,
                          len(_str) * 2, rect,
                          DT_SINGLELINE | DT_CENTER | DT_VCENTER)
        win32gui.EndPaint(hwnd, ps)
        win32gui.DragAcceptFiles(hwnd, 1)
    elif msg == WM_DESTROY:
        win32gui.PostQuitMessage(0)
    elif msg == WM_DROPFILES:
        hDropInfo = wParam
        filescount = win32api.DragQueryFile(hDropInfo)
        for i in range(filescount):
            filename = win32api.DragQueryFile(hDropInfo, i)
            files = get_files_list(filename)
            for _f in files:
                if not isSpecialDir(_f):
                    fileHandler(_f)

        win32api.DragFinish(hDropInfo)

    return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 11
0
    def wndProc(self, hWnd, message, wParam, lParam):
        if message == win32con.WM_PAINT:
            hdc, paintStruct = win32gui.BeginPaint(hWnd)

            dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0
            fontSize = self.fontSize
            win32gui.SetTextColor(hdc, self.color)
            # https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
            lf = win32gui.LOGFONT()
            lf.lfFaceName = "微軟正黑體"
            lf.lfHeight = int(round(dpiScale * fontSize))
            lf.lfWeight = 700
            # Use nonantialiased to remove the white edges around the text.
            lf.lfQuality = win32con.NONANTIALIASED_QUALITY
            hf = win32gui.CreateFontIndirect(lf)
            win32gui.SelectObject(hdc, hf)

            rect = win32gui.GetClientRect(hWnd)
            # https://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx
            win32gui.DrawText(
                hdc, self.text, -1, rect,
                win32con.DT_CENTER | win32con.DT_NOCLIP
                | win32con.DT_SINGLELINE | win32con.DT_VCENTER)
            win32gui.EndPaint(hWnd, paintStruct)
            return 0

        elif message == win32con.WM_DESTROY:
            # print('Closing the window.')
            win32gui.PostQuitMessage(0)
            return 0

        else:
            return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
Ejemplo n.º 12
0
def wndProc(hWnd, message, wParam, lParam):
    if message == win32con.WM_PAINT:
        hDC, paintStruct = win32gui.BeginPaint(hWnd)

        rect = win32gui.GetClientRect(hWnd)
        win32gui.DrawText(
            hDC,
            'Hello send by Python via Win32!',
            -1,
            rect,
            win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER)

        win32gui.EndPaint(hWnd, paintStruct)
        return 0

    elif message == win32con.WM_DESTROY:
        print('Being destroyed')
        win32gui.PostQuitMessage(0)
        return 0
    elif message == FullGenMessage:
        print("Founded new message from FullGen")
        print(wParam)
        print(lParam)
        return 0
    else:
        return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
 def drawtext(self, text):
     '''
     在鼠标所在为止写入一个字符串
     '''
     t = win32gui.GetDC(win32gui.GetDesktopWindow())
     w,h = win32api.GetSystemMetrics(0),win32api.GetSystemMetrics(1)
     x,y = win32api.GetCursorPos()
     win32gui.DrawText(t,text,-1,(x,y,w,h),8)
Ejemplo n.º 14
0
def drawtext(times):
    tim = time.time()
    x, y = random.randint(0, w), random.randint(0, h)
    while time.time() - tim < times:
        time.sleep(.001)
        r = 60
        xx, yy = map(int, [random.gauss(0, r) + x, random.gauss(0, r) + y])
        win32gui.DrawText(t, 'nihaoa', -1, (xx, yy, w, h), DT_BOTTOM)
Ejemplo n.º 15
0
 def drawTimerLabel(self,
                    hdc,
                    pos,
                    color=ColorCode.BLACK,
                    initialValue=0.0):
     win32gui.SetTextColor(hdc, color)
     win32gui.DrawText(hdc, '{0:.1f}'.format(initialValue), -1, pos,
                       win32con.DT_RIGHT | win32con.DT_VCENTER)
Ejemplo n.º 16
0
 def _draw_text(self, handle: int, box: tuple, text: str, color: tuple,
                font: (dict, tuple)) -> tuple:
     """Draw text in the given location"""
     font = self._build_font(font, self._get_dpi_scale(handle))
     gui.SelectObject(handle, font)
     gui.SetTextColor(handle, self._color(color))
     return gui.DrawText(
         handle, text, -1, box,
         con.DT_NOCLIP | con.DT_LEFT | con.DT_SINGLELINE | con.DT_TOP)
Ejemplo n.º 17
0
 def draw(self, device_context_handle):
     x2, y2 = self.x + self.width, self.y + self.height
     win32gui.DrawText(
         device_context_handle,
         self.text,
         -1,
         (self.x, self.y, x2, y2),
         TEXT_FORMAT
     )
Ejemplo n.º 18
0
def WndProc(hwnd, msg, wParam, lParam):
    if msg == WM_PAINT:
        hdc, ps = win32gui.BeginPaint(hwnd)
        rect = win32gui.GetClientRect(hwnd)
        win32gui.DrawText(hdc, 'GUI Python', len('GUI Python'), rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER)
        win32gui.EndPaint(hwnd, ps)
    if msg == WM_DESTROY:
        win32gui.PostQuitMessage(0)
    return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 19
0
    def Render(hWnd):
        hDC, paintStruct = win32gui.BeginPaint(hWnd)

        rect = win32gui.GetClientRect(hWnd)
        win32gui.DrawText(
            hDC,
            'Hello send by Python via Win32!',
            -1,
            rect,
            win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER)

        win32gui.EndPaint(hWnd, paintStruct)
        pass
Ejemplo n.º 20
0
    def WndProc(self, hWnd, message, wParam, lParam):
        if message == win32con.WM_PAINT:
            rect = win32gui.GetClientRect(hWnd)  # tuple(L,T,R,B)
            hDC, paintStruct = win32gui.BeginPaint(hWnd)
            win32gui.SetTextColor(hDC, win32api.RGB(255, 0, 0))
            win32gui.SetBkMode(hDC, 1)
            rect2 = (rect[0] + 10, rect[1] + 10, rect[2], rect[3])
            rect3 = (rect[0] + 10, rect[1] + 30, rect[2], rect[3])
            win32gui.DrawText(hDC, 'Overlay Test', -1, rect2,
                              win32con.DT_SINGLELINE | win32con.DT_NOCLIP)
            win32gui.DrawText(hDC, 'Test message2', -1, rect3,
                              win32con.DT_SINGLELINE | win32con.DT_NOCLIP)
            ###
            memDC = win32gui.CreateCompatibleDC(hDC)
            image1 = win32gui.LoadImage(None, "1111.bmp",
                                        win32con.IMAGE_BITMAP, 0, 0,
                                        win32con.LR_LOADFROMFILE)
            OldBitmap = win32gui.SelectObject(memDC, image1)

            if image1 == 0:
                print("image load error")
                exit(1)
            win32gui.BitBlt(hDC, 10, 50, 100, 100, memDC, 0, 0,
                            win32con.SRCCOPY)
            win32gui.SelectObject(memDC, OldBitmap)
            win32gui.DeleteObject(image1)
            win32gui.DeleteObject(memDC)

            win32gui.EndPaint(hWnd, paintStruct)

        elif message == win32con.WM_DESTROY:
            print("Being destroyed")
            win32gui.PostQuitMessage(0)

        else:
            return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
Ejemplo n.º 21
0
 def WndProc(self, hwnd, msg, wParam, lParam):
     if msg == win32con.WM_PAINT:
         print('WM_PAINT')
         hdc, ps = win32gui.BeginPaint(hwnd)
         rect = win32gui.GetClientRect(hwnd)
         win32gui.DrawText(
             hdc, 'GUI Python', len('GUI Python'), rect,
             win32con.DT_SINGLELINE | win32con.DT_CENTER
             | win32con.DT_VCENTER)
         win32gui.EndPaint(hwnd, ps)
     if msg == win32con.WM_DESTROY:
         print('WM_DESTROY')
         win32gui.PostQuitMessage(0)
     if msg == win32con.WM_DEVICECHANGE:
         print('WM_DEVICECHANGE')
         self.hotplugCallbackWin(hwnd, msg, wParam, lParam)
     return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 22
0
def wndProc(hWnd, message, wParam, lParam):
    if message == win32con.WM_PAINT:
        hDC, paintStruct = win32gui.BeginPaint(hWnd)
        rect = win32gui.GetClientRect(hWnd)
        win32gui.DrawText(
            hDC, 'Hello send by Python via Win32!', -1, rect,
            win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER)

        win32gui.EndPaint(hWnd, paintStruct)
        return 0
    elif message == win32con.WM_DESTROY:
        win32gui.PostQuitMessage(0)
        return 0
    elif message == FullGenMessage:
        connection.set("wParam", str(wParam))
        connection.set("lParam", str(lParam))
        return 0
    else:
        return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
Ejemplo n.º 23
0
def debugRender(hWnd, hdc, paintStruct):
    dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0
    fontSize = 12

    # http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
    lf = win32gui.LOGFONT()
    lf.lfFaceName = "Arial"
    lf.lfHeight = int(round(dpiScale * fontSize))
    #lf.lfWeight = 150
    # Use nonantialiased to remove the white edges around the text.
    lf.lfQuality = win32con.NONANTIALIASED_QUALITY
    hf = win32gui.CreateFontIndirect(lf)
    win32gui.SelectObject(hdc, hf)

    rect = win32gui.GetClientRect(hWnd)
    logging.debug(rect)
    # http://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx
    win32gui.DrawText(
        hdc, 'Text on the screen', -1, rect, win32con.DT_CENTER
        | win32con.DT_NOCLIP | win32con.DT_SINGLELINE | win32con.DT_VCENTER)
Ejemplo n.º 24
0
def write_text(text=""):
    hwin = win32gui.GetDesktopWindow()
    hdc = win32gui.GetDC(hwin)

    # 텍스트 옵션
    font = win32ui.CreateFont({"name": "Arial", "height": 64, "weight": 400})
    oldFont = win32gui.SelectObject(hdc, font.GetSafeHandle())

    #win32gui.SetTextColor(hdc, win32api.RGB(0,0,0))
    #win32gui.SetBkColor(hdc, win32api.RGB(255, 255, 255))

    rect = win32gui.GetClientRect(hwin)
    win32gui.DrawText(
        hdc, text, len(text), rect, win32con.DT_BOTTOM | win32con.DT_RIGHT
        | win32con.DT_SINGLELINE | win32con.DT_WORDBREAK
        #win32con.DT_CENTER|win32con.DT_VCENTER|win32con.DT_SINGLELINE|win32con.DT_WORDBREAK
    )

    win32gui.SelectObject(hdc, oldFont)
    win32gui.DeleteObject(font.GetSafeHandle())
    win32gui.ReleaseDC(hwin, hdc)
def wndProc(hWnd, message, wParam, lParam):
    if message == win32con.WM_PAINT:
        hdc, paintStruct = win32gui.BeginPaint(hWnd)
        print 'windProc'
        dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0
        fontSize = 80
        lf = win32gui.LOGFONT()
        lf.lfFaceName = "Times New Roman"
        lf.lfHeight = int(round(dpiScale * fontSize))
        hf = win32gui.CreateFontIndirect(lf)
        win32gui.SelectObject(hdc, hf)
        rect = win32gui.GetClientRect(hWnd)
        win32gui.DrawText(
            hdc, 'O', -1, rect, win32con.DT_CENTER | win32con.DT_NOCLIP
            | win32con.DT_SINGLELINE | win32con.DT_VCENTER)
        win32gui.EndPaint(hWnd, paintStruct)
        return 0
    elif message == win32con.WM_DESTROY:
        print 'Closing the window.'
        win32gui.PostQuitMessage(0)
        return 0
    else:
        return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
Ejemplo n.º 26
0
    def wndProc(self, hWnd, message, wParam, lParam):

        if message == win32con.WM_PAINT:
            hDC, paintStruct = win32gui.BeginPaint(hWnd)
            folder_with_ico_file = 'share' if hasattr(sys,
                                                      'frozen') else 'windows'
            filename = os.path.join(os.path.dirname(sys.argv[0]),
                                    folder_with_ico_file, 'bleachbit.ico')
            flags = win32con.LR_LOADFROMFILE
            hIcon = win32gui.LoadImage(0, filename, win32con.IMAGE_ICON, 0, 0,
                                       flags)

            # Default icon size seems to be 32 pixels so we center the icon vertically.
            default_icon_size = 32
            icon_top_margin = self._splash_screen_height - 2 * (
                default_icon_size + 2)
            win32gui.DrawIcon(hDC, 0, icon_top_margin, hIcon)
            # win32gui.DrawIconEx(hDC, 0, 0, hIcon, 64, 64, 0, 0, win32con.DI_NORMAL)

            rect = win32gui.GetClientRect(hWnd)
            textmetrics = win32gui.GetTextMetrics(hDC)
            text_left_margin = 2 * default_icon_size
            text_rect = (text_left_margin,
                         (rect[3] - textmetrics['Height']) // 2, rect[2],
                         rect[3])
            win32gui.DrawText(hDC, _("BleachBit is starting...\n"), -1,
                              text_rect, win32con.DT_WORDBREAK)
            win32gui.EndPaint(hWnd, paintStruct)
            return 0

        elif message == win32con.WM_DESTROY:
            win32gui.PostQuitMessage(0)
            return 0

        else:
            return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
Ejemplo n.º 27
0
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
font.lfWeight = 150
font.lfItalic = 1
font.lfUnderline = 1
hf = win32gui.CreateFontIndirect(font)
win32gui.SelectObject(pDC, hf)
win32gui.SetBkMode(pDC, win32con.TRANSPARENT)
win32gui.SetTextColor(pDC, win32api.RGB(0, 255, 0))
win32gui.DrawText(
    pDC, 'Printed by Python!', -1,
    (0, 0, int(printerwidth * .9), int(printerheight * .9)),
    win32con.DT_RIGHT | win32con.DT_BOTTOM | win32con.DT_SINGLELINE)
win32print.EndPage(pDC)
win32print.EndDoc(pDC)

win32print.ClosePrinter(p)
win32gui.DeleteObject(dcBM)
win32gui.DeleteObject(pcBM)
win32gui.DeleteObject(hf)
win32gui.DeleteDC(dDC)
win32gui.DeleteDC(dcDC)
win32gui.DeleteDC(pDC)
win32gui.DeleteDC(pcDC)
Ejemplo n.º 28
0
 def drawTextLabel(self, hdc, pos, color=ColorCode.BLACK, text=''):
     win32gui.SetTextColor(hdc, color)
     win32gui.DrawText(hdc, text, -1, pos,
                       win32con.DT_LEFT | win32con.DT_VCENTER)
Ejemplo n.º 29
0
def drawSimpleText(hDc, text, x, y):
    win32gui.DrawText(hDc, text, len(text),
                      (x, y, x + MAX_TEXT_WIDTH, y + MAX_TEXT_HEIGHT),
                      win32con.DT_TOP | win32con.DT_LEFT)
Ejemplo n.º 30
0
def drawSoldiers(hDc, dataContainer, globalLock, cX, cY, lineWidth=1):
    """
    win32gui.Rectangle(hDc, left, top, right, bottom)
    
    draw the box esp and the minimap
    """
    globalLock.acquire()
    viewTransform = dataContainer.viewMatrix
    viewOrigin = dataContainer.viewOrigin
    viewForwardVec = dataContainer.viewForwardVec
    fovY = dataContainer.fovY
    fovX = dataContainer.fovX

    # i'm using the old bf3 worldToScreen calculation, so do not need the aspect ratio any more
    #aspect = dataContainer.aspectRatio
    globalLock.release()

    projM = getProjectionMatrixBF3(0.06, 10000.0, fovX, fovY)

    # ============== initialize the minimap ================
    centerX, centerY = 200, 200
    boundaryX, boundaryY = 160, 160
    top, bottom = centerY - boundaryY, centerY + boundaryY
    left, right = centerX - boundaryX, centerX + boundaryX
    hPen = win32gui.CreatePen(win32con.PS_SOLID, 2, COLOR_BLUE)
    win32gui.SelectObject(hDc, hPen)
    win32gui.Rectangle(hDc, left, top, right, bottom)
    drawCrossHair(hDc,
                  centerX,
                  centerY,
                  size=159,
                  lineWidth=2,
                  color=COLOR_BLUE)
    # ======================================================

    # the consumer starts up - consuming n soldier objects at a time
    # n equals to the approximate size of the queue at that point
    for i in range(dataContainer.soldiers.qsize()):

        soldier = dataContainer.soldiers.get()

        # strictly speaking the soldier object can not be invalid (due to the producer-consumer
        # model), but just to be on the safe side...
        if not soldier.isValid():
            continue

        distanceToViewOrigin = viewOrigin.distanceTo(soldier.posVec4)

        # visible enemy footman: Green
        color = COLOR_RED if soldier.occluded else COLOR_GREEN

        if soldier.isVehicle:
            hPen = win32gui.CreatePen(win32con.PS_SOLID, 2, COLOR_YELLOW)
        else:
            hPen = win32gui.CreatePen(win32con.PS_SOLID, lineWidth, color)
        win32gui.SelectObject(hDc, hPen)

        # here is the same logic as in BF3, applies to other MVP transformation as well
        posV = soldier.posVec4.multToMat(viewTransform)
        posVP = posV.multToMat(projM)

        if abs(posVP.w) > 0.001 and posVP.z <= 0:
            # ============== draw soldier box esp ===============
            # important! this is different from BF3 (d3d)!!
            scrX = int(cX * (1 + posVP.x / posVP.w))
            scrY = int(cY * (1 - posVP.y / posVP.w))
            # draw text
            text = "%d(%d)" % (int(distanceToViewOrigin), int(soldier.health))
            win32gui.DrawText(hDc, text, len(text),
                              (scrX, scrY, scrX + 68, scrY + 14),
                              win32con.DT_TOP | win32con.DT_LEFT)
            # calculate the esp box size!
            # the reason I don't use the calculation is the scope will disturb the esp box
            if soldier.isVehicle:
                w, h = 6, 6
                win32gui.Rectangle(hDc, scrX - w / 2, scrY - h, scrX + w / 2,
                                   scrY)
            else:
                w, h = 4, 4  #getWidthHeight(distanceToViewOrigin, soldier.stance)
                win32gui.Rectangle(hDc, scrX - w / 2, scrY - h, scrX + w / 2,
                                   scrY)
            # ===================================================

        if posV.w > 0.001:
            # =========== draw soldier minimap spot ===========
            # calculate the planar coord while compensate for the viewing angle
            dx = posV.x / posV.w
            cosA = viewForwardVec.dotProduct(
                vector.Vector4(viewForwardVec.x, 0.0, viewForwardVec.z,
                               0.0).normalize())
            dy = posV.z / posV.w / abs(cosA)
            # limit the drawing to the defined minimap region
            dx = int(dx / 1.0 + centerX)
            dy = int(dy / 1.0 + centerY)
            if dx < left: dx = left
            if dx > right: dx = right
            if dy < top: dy = top
            if dy > bottom: dy = bottom
            # draw spot
            pColor = COLOR_RED if soldier.occluded else COLOR_GREEN
            hPen = win32gui.CreatePen(win32con.PS_SOLID, 2, pColor)
            win32gui.SelectObject(hDc, hPen)
            win32gui.Rectangle(hDc, dx, dy, dx + 2, dy + 2)