python类DestroyWindow()的实例源码

win32_counter.py 文件源码 项目:KeyCounter 作者: Microcore 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
taskbar_widget.py 文件源码 项目:StuffShare 作者: StuffShare 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd)
win32gui_devicenotify.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号