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

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

项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam == win32con.WM_LBUTTONUP:
            print "You clicked me."
        elif lparam == win32con.WM_LBUTTONDBLCLK:
            print "You double-clicked me - goodbye"
            win32gui.DestroyWindow(self.hwnd)
        elif lparam == win32con.WM_RBUTTONUP:
            print "You right clicked me."
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1023, gbk("????"))
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1024, gbk("????"))
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1025, gbk("????"))
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1026, gbk("????"))
            pos = win32gui.GetCursorPos()
            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam==win32con.WM_LBUTTONUP:
            print "You clicked me."
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            print "You double-clicked me - goodbye"
            win32gui.DestroyWindow(self.hwnd)
        elif lparam==win32con.WM_RBUTTONUP:
            print "You right clicked me."
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Say Hello")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit program" )
            pos = win32gui.GetCursorPos()
            # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def TestSetWorldTransform():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_1'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_1
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindow(wc.lpszClassName,
        'Spin the Lobster!',
        win32con.WS_CAPTION|win32con.WS_VISIBLE,
        100,100,900,900, 0, 0, 0, None)
    for x in xrange(500):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.01)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(wc.lpszClassName, None)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def TestGradientFill():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_2'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_2
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindowEx(0, class_atom,'Kaleidoscope',
        win32con.WS_CAPTION|win32con.WS_VISIBLE|win32con.WS_THICKFRAME|win32con.WS_SYSMENU,
        100,100,900,900, 0, 0, 0, None)
    s=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, s|win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA)
    for x in xrange(30):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.3)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(class_atom,None)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam==win32con.WM_LBUTTONUP:
            print("You clicked me.")
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            print("You double-clicked me - goodbye")
            win32gui.DestroyWindow(self.hwnd)
        elif lparam==win32con.WM_RBUTTONUP:
            print("You right clicked me.")
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Say Hello")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit program" )
            pos = win32gui.GetCursorPos()
            # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def TestSetWorldTransform():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_1'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_1
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindow(wc.lpszClassName,
        'Spin the Lobster!',
        win32con.WS_CAPTION|win32con.WS_VISIBLE,
        100,100,900,900, 0, 0, 0, None)
    for x in range(500):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.01)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(wc.lpszClassName, None)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def TestGradientFill():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_2'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_2
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindowEx(0, class_atom,'Kaleidoscope',
        win32con.WS_CAPTION|win32con.WS_VISIBLE|win32con.WS_THICKFRAME|win32con.WS_SYSMENU,
        100,100,900,900, 0, 0, 0, None)
    s=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, s|win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA)
    for x in range(30):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.3)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(class_atom,None)
项目:PyUIA    作者:xiaoxiayu    | 项目源码 | 文件源码
def __init__(self):
        # FX_Window HND
        self.Win32Window = ''
        self.ProcessID = ''
        self.ThreadID = ''
        self.Title = ''


##def FX_CompareWindow(window0, window1):
##    if (window0.Window.GetWin32Window() != window1.Window.GetWin32Window()):
##        if (window0.ProcessID != window1.ProcessID):
##            return 1
##        else:
##            return -1    
##    return 0

##def FX_CloseWindow(window):
##    win32gui.CloseWindow(window.GetWin32Window())
##
##def FX_DestoryWindow(window):
##    win32gui.DestroyWindow(window.GetWin32Window())
##
##
项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def execute_menu_option(self, id):
        menu_action = self.menu_actions_by_id[id]
        if menu_action == self.QUIT:
            win32gui.DestroyWindow(self.hwnd)
        else:
            menu_action(self)
项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def OnCommand(self, hwnd, msg, wparam, lparam):
        id = win32api.LOWORD(wparam)
        if id == 1023:
            print '1023'
        elif id == 1024:
            print "????"
        elif id == 1025:
            self.netkeeper.disconnect()
            print "????"
        elif id == 1026:
            print "????"
            settings.RUNNING = False
            win32gui.DestroyWindow(self.hwnd)
        else:
            print "Unknown command -", id
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed view window"

    # Message handlers.
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed scintilla window"
项目:touch-pay-client    作者:HackPucBemobi    | 项目源码 | 文件源码
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
项目:true_review_web2py    作者:lucadealfaro    | 项目源码 | 文件源码
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
项目:spc    作者:whbrewer    | 项目源码 | 文件源码
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
项目:Problematica-public    作者:TechMaz    | 项目源码 | 文件源码
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
项目:rekall-agent-server    作者:rekall-innovations    | 项目源码 | 文件源码
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed view window"

    # Message handlers.
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed scintilla window"
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnCommand(self, hwnd, msg, wparam, lparam):
        id = win32api.LOWORD(wparam)
        if id == 1023:
            import win32gui_dialog
            win32gui_dialog.DemoModal()
        elif id == 1024:
            print "Hello"
        elif id == 1025:
            print "Goodbye"
            win32gui.DestroyWindow(self.hwnd)
        else:
            print "Unknown command -", id
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnClose(self, hwnd, msg, wparam, lparam):
        win32gui.DestroyWindow(hwnd)

    # We need to arrange to a WM_QUIT message to be sent to our
    # PumpMessages() loop.
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnClose(self, hwnd, msg, wp, lp):
        win32clipboard.ChangeClipboardChain(hwnd, self.hwndNextViewer)
        win32gui.DestroyWindow(hwnd)
        win32gui.PostQuitMessage(0)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print("Destroyed view window")

    # Message handlers.
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print("Destroyed scintilla window")
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def TestDeviceNotifications(dir_names):
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_devicenotify'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc={win32con.WM_DEVICECHANGE:OnDeviceChange}
    class_atom=win32gui.RegisterClass(wc)
    hwnd = win32gui.CreateWindow(wc.lpszClassName,
        'Testing some devices',
        # no need for it to be visible.
        win32con.WS_CAPTION,
        100,100,900,900, 0, 0, 0, None)

    hdevs = []
    # Watch for all USB device notifications
    filter = win32gui_struct.PackDEV_BROADCAST_DEVICEINTERFACE(
                                        GUID_DEVINTERFACE_USB_DEVICE)
    hdev = win32gui.RegisterDeviceNotification(hwnd, filter,
                                               win32con.DEVICE_NOTIFY_WINDOW_HANDLE)
    hdevs.append(hdev)
    # and create handles for all specified directories
    for d in dir_names:
        hdir = win32file.CreateFile(d, 
                                    winnt.FILE_LIST_DIRECTORY, 
                                    winnt.FILE_SHARE_READ | winnt.FILE_SHARE_WRITE | winnt.FILE_SHARE_DELETE,
                                    None, # security attributes
                                    win32con.OPEN_EXISTING,
                                    win32con.FILE_FLAG_BACKUP_SEMANTICS | # required privileges: SE_BACKUP_NAME and SE_RESTORE_NAME.
                                    win32con.FILE_FLAG_OVERLAPPED,
                                    None)

        filter = win32gui_struct.PackDEV_BROADCAST_HANDLE(hdir)
        hdev = win32gui.RegisterDeviceNotification(hwnd, filter,
                                          win32con.DEVICE_NOTIFY_WINDOW_HANDLE)
        hdevs.append(hdev)

    # now start a message pump and wait for messages to be delivered.
    print("Watching", len(hdevs), "handles - press Ctrl+C to terminate, or")
    print("add and remove some USB devices...")
    if not dir_names:
        print("(Note you can also pass paths to watch on the command-line - eg,")
        print("pass the root of an inserted USB stick to see events specific to")
        print("that volume)")
    while 1:
        win32gui.PumpWaitingMessages()
        time.sleep(0.01)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(wc.lpszClassName, None)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnCommand(self, hwnd, msg, wparam, lparam):
        id = win32api.LOWORD(wparam)
        if id == 1023:
            import win32gui_dialog
            win32gui_dialog.DemoModal()
        elif id == 1024:
            print("Hello")
        elif id == 1025:
            print("Goodbye")
            win32gui.DestroyWindow(self.hwnd)
        else:
            print("Unknown command -", id)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnClose(self, hwnd, msg, wparam, lparam):
        win32gui.DestroyWindow(hwnd)

    # We need to arrange to a WM_QUIT message to be sent to our
    # PumpMessages() loop.
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnClose(self, hwnd, msg, wp, lp):
        win32clipboard.ChangeClipboardChain(hwnd, self.hwndNextViewer)
        win32gui.DestroyWindow(hwnd)
        win32gui.PostQuitMessage(0)
项目:slugiot-client    作者:slugiot    | 项目源码 | 文件源码
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
项目:KivySystemTrayApp    作者:twister077    | 项目源码 | 文件源码
def execute_menu_option(self, id):
        menu_action = self.menu_actions_by_id[id]      
        if menu_action == self.QUIT:
            win32gui.DestroyWindow(self.hwnd)
        else:
            menu_action(self)
项目:KeyCounter    作者:Microcore    | 项目源码 | 文件源码
def stop(self):
        if getattr(self, 'hook', None) is not None:
            del self.hook
        if self.HWND is not None:
            win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, (self.HWND, 0))
            # win32gui.PostMessage(self.HWND, win32con.WM_CLOSE, 0, 0)
            win32gui.DestroyWindow(self.HWND)
            self.HWND = None
        self.clear_instance_check_event()

        super(KeyCounter, self).stop()
        raise SystemExit(0)
项目:StuffShare    作者:StuffShare    | 项目源码 | 文件源码
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def TestDeviceNotifications(dir_names):
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_devicenotify'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc={win32con.WM_DEVICECHANGE:OnDeviceChange}
    class_atom=win32gui.RegisterClass(wc)
    hwnd = win32gui.CreateWindow(wc.lpszClassName,
        'Testing some devices',
        # no need for it to be visible.
        win32con.WS_CAPTION,
        100,100,900,900, 0, 0, 0, None)

    hdevs = []
    # Watch for all USB device notifications
    filter = win32gui_struct.PackDEV_BROADCAST_DEVICEINTERFACE(
                                        GUID_DEVINTERFACE_USB_DEVICE)
    hdev = win32gui.RegisterDeviceNotification(hwnd, filter,
                                               win32con.DEVICE_NOTIFY_WINDOW_HANDLE)
    hdevs.append(hdev)
    # and create handles for all specified directories
    for d in dir_names:
        hdir = win32file.CreateFile(d, 
                                    winnt.FILE_LIST_DIRECTORY, 
                                    winnt.FILE_SHARE_READ | winnt.FILE_SHARE_WRITE | winnt.FILE_SHARE_DELETE,
                                    None, # security attributes
                                    win32con.OPEN_EXISTING,
                                    win32con.FILE_FLAG_BACKUP_SEMANTICS | # required privileges: SE_BACKUP_NAME and SE_RESTORE_NAME.
                                    win32con.FILE_FLAG_OVERLAPPED,
                                    None)

        filter = win32gui_struct.PackDEV_BROADCAST_HANDLE(hdir)
        hdev = win32gui.RegisterDeviceNotification(hwnd, filter,
                                          win32con.DEVICE_NOTIFY_WINDOW_HANDLE)
        hdevs.append(hdev)

    # now start a message pump and wait for messages to be delivered.
    print "Watching", len(hdevs), "handles - press Ctrl+C to terminate, or"
    print "add and remove some USB devices..."
    if not dir_names:
        print "(Note you can also pass paths to watch on the command-line - eg,"
        print "pass the root of an inserted USB stick to see events specific to"
        print "that volume)"
    while 1:
        win32gui.PumpWaitingMessages()
        time.sleep(0.01)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(wc.lpszClassName, None)