Python win32gui.PostQuitMessage() Examples

The following are 22 code examples of win32gui.PostQuitMessage(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32gui , or try the search function .
Example #1
Source File: win32gui_taskbar.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def OnDestroy(self, hwnd, msg, wparam, lparam):
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0) # Terminate the app. 
Example #2
Source File: window.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def _on_close(self, hwnd, msg, wparam, lparam):
        win32gui.PostQuitMessage(0) 
Example #3
Source File: explorer_browser.py    From Email_My_PC with MIT License 5 votes vote down vote up
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) 
Example #4
Source File: winapi.py    From gui-o-matic with GNU Lesser General Public License v3.0 5 votes vote down vote up
def quit(self):
        win32gui.PostQuitMessage(0)     
        raise KeyboardInterrupt("User quit") 
Example #5
Source File: check_external_drive.py    From BrainDamage with Apache License 2.0 5 votes vote down vote up
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 
Example #6
Source File: gui_win.py    From ComicStreamer with Apache License 2.0 5 votes vote down vote up
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. 
Example #7
Source File: shell.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def OnDestroy(self, hwnd, msg, wparam, lparam):
        nid = (self.main_frame.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0)  # Terminate the app. 
Example #8
Source File: shell.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def close(self):
        win32gui.PostQuitMessage(0) 
Example #9
Source File: notice_dlg.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def OnClose(self, hwnd, msg, wparam, lparam):
        print("OnClose")
        # win32gui.EndDialog(hwnd, 0)
        self.hide()
        # win32gui.PostQuitMessage(0) 
Example #10
Source File: console.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def OnClose(self, hwnd, msg, wparam, lparam):
        print("OnClose")
        # win32gui.EndDialog(hwnd, 0)
        self.hide()
        # win32gui.PostQuitMessage(0) 
Example #11
Source File: console.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def OnDestroy(self, hwnd, msg, wparam, lparam):
        # print("OnDestroy")
        # win32gui.PostQuitMessage(0)
        win32gui.EndDialog(hwnd, 0)
        self.hwnd = None 
Example #12
Source File: window.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def close(self):
        win32gui.PostQuitMessage(0) 
Example #13
Source File: explorer_browser.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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) 
Example #14
Source File: window.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def _on_destroy(self, hwnd, msg, wparam, lparam):
        win32gui.PostQuitMessage(0) 
Example #15
Source File: systray.py    From OpenBazaar-Installer with MIT License 5 votes vote down vote up
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. 
Example #16
Source File: __init__.py    From pyrexecd with MIT License 5 votes vote down vote up
def _destroy(klass, hwnd, msg, wparam, lparam):
        del klass._instance[hwnd]
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, (hwnd, 0))
        win32gui.PostQuitMessage(0)
        return 
Example #17
Source File: tray.py    From MouseTracks with GNU General Public License v3.0 5 votes vote down vote up
def OnDestroy(self, hwnd, msg, wparam, lparam):
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0)
        self.logger.info('Window destroyed.') 
Example #18
Source File: tcp.py    From peach with Mozilla Public License 2.0 5 votes vote down vote up
def enumCallback(hwnd, windowName):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            try:

                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    return

                (threadId, processId) = win32process.GetWindowThreadProcessId(hwnd)

                # Send WM_CLOSE message
                try:
                    win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    win32gui.PostQuitMessage(hwnd)
                except:
                    pass

                # Give it upto 5 sec
                for i in range(100):
                    if win32process.GetExitCodeProcess(processId) != win32con.STILL_ACTIVE:
                        # Process exited already
                        return

                    time.sleep(0.25)

                try:
                    # Kill application
                    win32process.TerminateProcess(processId, 0)
                except:
                    pass
            except:
                pass 
Example #19
Source File: SysTrayIcon.py    From LIFX-Control-Panel with MIT License 5 votes vote down vote up
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. 
Example #20
Source File: win32gui_dialog.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DemoCreateWindow():
    w=DemoWindow()
    w.CreateWindow()
    # PumpMessages runs until PostQuitMessage() is called by someone.
    win32gui.PumpMessages() 
Example #21
Source File: win32gui_dialog.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def OnDestroy(self, hwnd, msg, wparam, lparam):
        win32gui.PostQuitMessage(0) # Terminate the app.

# An implementation suitable for use with the Win32 Dialog functions. 
Example #22
Source File: desktopmanager.py    From ironpython2 with Apache License 2.0 4 votes vote down vote up
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)