Ejemplo n.º 1
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.º 2
0
    def wnd_proc(self, hwnd, message, wParam, lParam):  # wmca MFC 콜백 처리
        # if wParam == CA_DISCONNECTED:
        #     print("Goodbye")/
        #     win32gui.PostQuitMessage(0)
        #     win32gui.DestroyWindow(self.hwnd)
        # el
        if wParam == CA_CONNECTED:  # 로그인 성공
            print("로그인 성공")
            # self.response.append({"login": "******"})
            win32gui.PostQuitMessage(
                0)  # mfc 메시지 루프 종료 (메시지를 받고 종료 처리 뒷 프로세스 실행을 위함)
        elif wParam == CA_SOCKETERROR:  # 통신 오류 발생
            print("통신 오류 발생")
        elif wParam == CA_RECEIVEDATA:  # 서비스 응답 수신(TR)
            print("서비스 응답 수신(TR)")
            sz_block_name, sz_block_data = self.on_wm_receivedata(lParam)
            self.response[sz_block_name] = sz_block_data
        elif wParam == CA_RECEIVESISE:  # 실시간 데이터 수신(BC)
            print("실시간 데이터 수신(BC)")
            self.response['realtime'] = self.on_wm_receivesise(lParam)
        elif wParam == CA_RECEIVEMESSAGE:  # 상태 메시지 수신 (입력값이 잘못되었을 경우 문자열형태로 설명이 수신됨)
            msg_cd, user_msg = self.on_wm_receivemessage(lParam)
            self.response[msg_cd] = user_msg
            win32gui.PostQuitMessage(0)
        elif wParam == CA_RECEIVECOMPLETE:  # 서비스 처리 완료
            print("서비스 처리 완료")
            win32gui.PostQuitMessage(
                0)  # mfc 메시지 루프 종료 (메시지를 받고 종료 처리 뒷 프로세스 실행을 위함)
        elif wParam == CA_RECEIVEERROR:  # 서비스 처리중 오류 발생 (입력값 오류등)
            print("서비스 처리중 오류 발생 (입력값 오류등)")

        return win32gui.DefWindowProc(hwnd, message, wParam, lParam)
Ejemplo n.º 3
0
def wndProc(hWnd, message, wParam, lParam):
    if not hasattr(wndProc, 'cxClient'):
        wndProc.cxClient = 0
        wndProc.cyClient = 0

    if message == win32con.WM_SIZE:
        wndProc.cxClient = win32gui.LOWORD(lParam)  # 附加参数的低位字保存窗口的宽度
        wndProc.cyClient = win32gui.HIWORD(lParam)  # 附加参数的高位字保存窗口的高度

    if message == win32con.WM_PAINT:
        hdc, paintStruct = win32gui.BeginPaint(hWnd)  # 获取窗口的dc和窗口客户区所需要的信息的结构
        win32gui.MoveToEx(hdc, 0, int(wndProc.cyClient /
                                      2))  # 移动到直线的起始点,这里比win32 API少了最后一个参数
        win32gui.LineTo(hdc, wndProc.cxClient,
                        int(wndProc.cyClient / 2))  # 画出直线
        vertices = list()  # 定义一个列表用来存储点,形式为[x,y]的形式
        point = list()  # 定义一个列表用来存储一系列作图的点
        for i in range(NUM):
            vertices = []
            vertices.append(int(i * wndProc.cxClient / NUM))  # 计算出x坐标
            vertices.append(
                int(wndProc.cyClient / 2 *
                    (1 - math.sin(2 * math.pi * i / NUM))))  # 计算出y坐标
            point.append(tuple(vertices))  # 将点添加到列表当中
        win32gui.Polyline(hdc, point)  # 画出正弦图像
        win32gui.EndPaint(hWnd, paintStruct)  # 关闭dc
        return 0

    if message == win32con.WM_DESTROY:
        win32gui.PostQuitMessage(0)  # 发送消息,退出窗口的进程
        return 0
    else:
        return win32gui.DefWindowProc(hWnd, message, wParam,
                                      lParam)  # 其他消息路由给操作系统处理
Ejemplo n.º 4
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.º 5
0
    def wndProc_edge(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 + 12
            win32gui.SetTextColor(hdc, self.color_edge)
            # 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.DrawTextW(
                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.º 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)
 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.º 8
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.º 9
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)
Ejemplo n.º 10
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.º 11
0
 def window_callback(self, hwnd, nMsg, wParam, lParam):
     if nMsg == win32con.WM_CLOSE:
         log.debug('WM_CLOSE')
         win32gui.DestroyWindow(hwnd)
     elif nMsg == win32con.WM_DESTROY:
         log.debug('WM_DESTROY')
         win32gui.PostQuitMessage(0)
     elif nMsg == win32con.WM_DEVICECHANGE:
         log.debug('WM_DEVICECHANGE')
         if wParam in [
                 win32con.DBT_DEVICEARRIVAL,
                 win32con.DBT_DEVICEREMOVECOMPLETE
         ]:
             # Unpack the 'lp' into the appropriate DEV_BROADCAST_* structure,
             # using the self-identifying data inside the DEV_BROADCAST_HDR.
             try:
                 info = win32gui_struct.UnpackDEV_BROADCAST(lParam)
             except NotImplementedError:
                 info = None
             log.debug(
                 "Device change notification: nMsg=%s, wParam=%s, info=%s:"
                 % (nMsg, wParam, str(info)))
             inserted = True if wParam == win32con.DBT_DEVICEARRIVAL else False
             self._cbk(inserted, info)
         return True
     else:
         log.debug('other message nMsg = %d' % nMsg)
     return win32gui.DefWindowProc(hwnd, nMsg, wParam, lParam)
Ejemplo n.º 12
0
 def wndProc(self, hwnd, msg, wParam, lParam):
     if msg == win32con.WM_SIZE: pass
     if msg == win32con.WM_PAINT: pass
     if msg == win32con.WM_CLOSE: pass
     if msg == win32con.WM_DESTROY:
         nid = (self.hwnd, 0)
         win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
     return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 13
0
def wndProc(hwnd, msg, wParam, lParam):
    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 == 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.º 14
0
 def wndProc(hwnd, msg, wParam, lParam):
     if msg == win32con.WM_SIZE: print("message: WM_SIZE")
     if msg == win32con.WM_PAINT: print("message: WM_PAINT")
     if msg == win32con.WM_CLOSE: print("message: WM_CLOSE")
     if msg == win32con.WM_DESTROY:
         timer_continue = 0
         print("message: WM_DESTROY")
         win32gui.PostQuitMessage(0)
     return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 15
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.º 16
0
 def _draw(self, window, message, w, l):
     """Callback for events on the window"""
     if message == con.WM_PAINT:
         return self._paint(window, message, w, l)
     elif message == con.WM_DESTROY:
         gui.PostQuitMessage(0)
         return 0
     else:
         return gui.DefWindowProc(window, message, w, l)
Ejemplo n.º 17
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.º 18
0
def WndProc(hwnd, msg, wParam, lParam):
    if msg == WM_PAINT:
        rect = Rect()
        user32.GetClientRect(hwnd, byref(rect))
        window.wkeResize(webview, rect.Right - rect.Left,
                         rect.Bottom - rect.Top)
    if msg == WM_DESTROY:
        win32gui.PostQuitMessage(0)
        return 0
    return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 19
0
 def wndProc(self, hwnd, msg, wParam, lParam):
     if self.getword_loaded and msg == self.MOUSEHOOK_CAPTURE_OK:
         print 'MOUSEHOOK_CAPTURE_OK'
         self._capture_text()
     if msg == win32con.WM_CLOSE:
         print 'WM_CLOSE'
         self._del_getword()
     if msg == win32con.WM_DESTROY:
         print 'WM_DESTROY'
         win32gui.PostQuitMessage(0)
     return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 20
0
    def __WndProc(self, hwnd, msg, wparam, lparam):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if self.WndProcHndlr(hwnd, msg, wparam, lparam) is None:
            return 0

        if msg == con.WM_DESTROY:
            #gui.UnregisterClass(self.wclass, self.hinst)
            gui.PostQuitMessage(0)
            return 0

        return gui.DefWindowProc(hwnd, msg, wparam, lparam)
Ejemplo n.º 21
0
def icon_wndproc(hwnd, msg, wp, lp):
    """Window proc for the tray icons"""
    if lp == win32con.WM_LBUTTONDOWN:
        ## popup menu won't disappear if you don't do this
        win32gui.SetForegroundWindow(hwnd)

        curr_desktop = win32service.OpenInputDesktop(0, True, win32con.MAXIMUM_ALLOWED)
        curr_desktop_name = win32service.GetUserObjectInformation(
            curr_desktop, win32con.UOI_NAME
        )
        winsta = win32service.GetProcessWindowStation()
        desktops = winsta.EnumDesktops()
        m = win32gui.CreatePopupMenu()
        desktop_cnt = len(desktops)
        ## *don't* create an item 0
        for d in range(1, desktop_cnt + 1):
            mf_flags = win32con.MF_STRING
            ## if you switch to winlogon yourself, there's nothing there and you're stuck
            if desktops[d - 1].lower() in ("winlogon", "disconnect"):
                mf_flags = mf_flags | win32con.MF_GRAYED | win32con.MF_DISABLED
            if desktops[d - 1] == curr_desktop_name:
                mf_flags = mf_flags | win32con.MF_CHECKED
            win32gui.AppendMenu(m, mf_flags, d, desktops[d - 1])
        win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt + 1, "Create new ...")
        win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt + 2, "Exit")

        x, y = win32gui.GetCursorPos()
        d = win32gui.TrackPopupMenu(
            m,
            win32con.TPM_LEFTBUTTON | win32con.TPM_RETURNCMD | win32con.TPM_NONOTIFY,
            x,
            y,
            0,
            hwnd,
            None,
        )
        win32gui.PumpWaitingMessages()
        win32gui.DestroyMenu(m)
        if d == desktop_cnt + 1:  ## Create new
            get_new_desktop_name(hwnd)
        elif d == desktop_cnt + 2:  ## Exit
            win32gui.PostQuitMessage(0)
            win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, window_info[hwnd])
            del window_info[hwnd]
            origin_desktop.SwitchDesktop()
        elif d > 0:
            hdesk = win32service.OpenDesktop(
                desktops[d - 1], 0, 0, win32con.MAXIMUM_ALLOWED
            )
            hdesk.SwitchDesktop()
        return 0
    else:
        return win32gui.DefWindowProc(hwnd, msg, wp, lp)
Ejemplo n.º 22
0
 def WndProc(self, hwnd, msg, wParam, lParam):
     # 经过试验得到这2个参数,分别代表点击了消息窗口(然后窗口关闭了)和窗口自动关闭。
     # 在以上情况下关闭窗口
     if lParam == win32con.WM_PSD_ENVSTAMPRECT:
         self.LC(self)
     if lParam == win32con.WM_PSD_GREEKTEXTRECT:
         self.AC(self)
     if msg == win32con.WM_DESTROY:
         nid = (self.hwnd, 0)
         win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
         win32gui.PostQuitMessage(0)  # Terminate the app.
     return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
Ejemplo n.º 23
0
 def WndProc(hWnd, message, wParam, lParam):
     if message == win32con.WM_PAINT:
         Render(hWnd)
         return 0
     elif message == win32con.WM_CREATE:
         return 0
     elif message == win32con.WM_DESTROY:
         print('Being destroyed')
         win32gui.PostQuitMessage(0)
         return 0
     else:
         return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
Ejemplo n.º 24
0
 def _wndproc(self, hwnd, msg, wParam, lParam):
     #log("_wndproc called with %s,%s,%s,%s"%(hwnd,msg,wParam,lParam))
     try:
         window = self.widget_map[hwnd]
     except:
         #log("NO WINDOW TO DISPATCH???")
         return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
     try:
         _dispatch = self._dispatch.get(msg, _dispatch_DEFAULT)
         x = _dispatch(window, hwnd, msg, wParam, lParam)
     except:
         x = -1
     return x
Ejemplo n.º 25
0
def proc(onkey, hwnd, msg, wparam, lparam):
    try:
        if msg == WM_INPUT:
            hRawInput = lparam
            ri = RAWINPUT()
            cbSize = wintypes.UINT(ctypes.sizeof(ri))
            r = user32.GetRawInputData(hRawInput, RID_INPUT, ctypes.byref(ri),
                                       ctypes.byref(cbSize),
                                       ctypes.sizeof(RAWINPUTHEADER))
            rk = ri.keyboard
            ev = RawKeyEvent(ri.keyboard)
            onkey(ev)
        return win32gui.DefWindowProc(hwnd, msg, wparam, lparam)
    except KeyboardInterrupt:
        exit(0)
Ejemplo n.º 26
0
    def winProc(self, hwnd, msg, wparam, lparam):
        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.º 27
0
def wndProc(hWnd, message, wParam, lParam):
    global hdc
    if message == win32con.WM_PAINT:
        hdc, paintStruct = win32gui.BeginPaint(hWnd)
        debugRender(hWnd, hdc, paintStruct)

        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.º 28
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.º 29
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.º 30
0
    def wndProc(self, hwnd, msg, wParam, lParam):  # 消息处理
        if msg == WCON.WM_DESTROY:
            win32gui.PostQuitMessage(0)

        if msg == WCON.WM_DRAWCLIPBOARD:  # 当剪切板更新的时候收到这个消息
            utxt = None
            btxt = None
            try:  # 有时候打不开会出异常
                WCB.OpenClipboard()
                if WCB.IsClipboardFormatAvailable(
                        WCON.CF_UNICODETEXT):  # 判断是否有指定的内容
                    utxt = WCB.GetClipboardData(WCON.CF_UNICODETEXT)
                    # if utxt.find('http') != -1:
                    #     utxt = utxt[utxt.find('http'):]
                if WCB.IsClipboardFormatAvailable(WCON.CF_TEXT):
                    btxt = WCB.GetClipboardData(WCON.CF_TEXT)
                    # if btxt.find('http') != -1:
                    #     btxt = btxt[btxt.find('http'):]
                    WCB.CloseClipboard()
            except Exception as e:
                print("error:", e)
            # finally:

            ok = False  # 依次尝试打印Unicode和字节码,ok是打印成功标志位
            if utxt:
                try:
                    if utxt.find('http') != -1:
                        utxt = utxt[utxt.find('http'):]
                    print("UNICODE:", utxt)
                    ok = True
                except Exception as e:
                    print(u'UNICODE打印失败:', e)

            if btxt and not ok:
                try:
                    print("GBK:", btxt.decode('gbk'))
                except Exception as e:
                    print(u'GBK打印失败:', e)

        return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)