Python win32gui 模块,PostQuitMessage() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用win32gui.PostQuitMessage()

项目:KeyCounter    作者:Microcore    | 项目源码 | 文件源码
def start(self):
        if self.instance_running():
            try:
                self.stop()
            except SystemExit:
                return win32gui.PostQuitMessage(0)

        # Load today's count data back from data file
        super(KeyCounter, self).start()

        self.hook_keyboard()
        self.create_window()
        self.update_tray_icon()

        while 1:
            try:
                win32event.MsgWaitForMultipleObjects(
                    [],
                    0,
                    self.MSPF,
                    win32event.QS_ALLEVENTS
                )
                win32gui.PumpWaitingMessages()
            except SystemExit:
                win32gui.PostQuitMessage(0)
项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def destroy(self, hwnd, msg, wparam, lparam):
        if self.on_quit: self.on_quit(self)
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0)  # Terminate the app.
项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0)  # Terminate the app.
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        print "tearing down ExplorerBrowser..."
        self.eb.Unadvise(self.event_cookie)
        self.eb.Destroy()
        self.eb = None
        print "shutting down app..."
        win32gui.PostQuitMessage(0)
项目:QiniuSync    作者:beyondskyway    | 项目源码 | 文件源码
def destroy(self, hwnd, msg, wparam, lparam):
        if self.on_quit:
            self.on_quit()
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0) # Terminate the app.
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        print "tearing down ExplorerBrowser..."
        self.eb.Unadvise(self.event_cookie)
        self.eb.Destroy()
        self.eb = None
        print "shutting down app..."
        win32gui.PostQuitMessage(0)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0) # Terminate the app.
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        win32gui.PostQuitMessage(0) # Terminate the app.

# An implementation suitable for use with the Win32 Dialog functions.
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def DemoCreateWindow():
    w=DemoWindow()
    w.CreateWindow()
    # PumpMessages runs until PostQuitMessage() is called by someone.
    win32gui.PumpMessages()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        print("tearing down ExplorerBrowser...")
        self.eb.Unadvise(self.event_cookie)
        self.eb.Destroy()
        self.eb = None
        print("shutting down app...")
        win32gui.PostQuitMessage(0)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0) # Terminate the app.
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnDestroy(self, hwnd, msg, wparam, lparam):
        win32gui.PostQuitMessage(0) # Terminate the app.

# An implementation suitable for use with the Win32 Dialog functions.
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def DemoCreateWindow():
    w=DemoWindow()
    w.CreateWindow()
    # PumpMessages runs until PostQuitMessage() is called by someone.
    win32gui.PumpMessages()
项目:BrainDamage    作者:mehulj94    | 项目源码 | 文件源码
def onDeviceChange (self, hwnd, msg, wparam, lparam):
    global DRIVE
    global FLAG
    dev_broadcast_hdr = DEV_BROADCAST_HDR.from_address (lparam)

    if wparam == DBT_DEVICEARRIVAL:
      if dev_broadcast_hdr.dbch_devicetype == DBT_DEVTYP_VOLUME:
        dev_broadcast_volume = DEV_BROADCAST_VOLUME.from_address (lparam)
        drive_letter = drive_from_mask (dev_broadcast_volume.dbcv_unitmask)
        DRIVE = chr (ord ("A") + drive_letter)
        print "[*] Drive Found: ", DRIVE + ":\\"
        FLAG = True
        win32gui.PostQuitMessage(0)
        #win32gui.PostQuitMessage(0)
    return 1
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)