Python win32gui.PumpWaitingMessages() Examples
The following are 14
code examples of win32gui.PumpWaitingMessages().
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_demo.py From ironpython2 with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: win32gui_demo.py From ironpython2 with Apache License 2.0 | 6 votes |
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)
Example #3
Source File: timer_demo.py From ironpython2 with Apache License 2.0 | 5 votes |
def demo (delay=1000, stop=10): g = glork(delay, stop) # Timers are message based - so we need # To run a message loop while waiting for our timers # to expire. start_time = time.time() while 1: # We can't simply give a timeout of 30 seconds, as # we may continouusly be recieving other input messages, # and therefore never expire. rc = win32event.MsgWaitForMultipleObjects( (g.event,), # list of objects 0, # wait all 500, # timeout win32event.QS_ALLEVENTS, # type of input ) if rc == win32event.WAIT_OBJECT_0: # Event signalled. break elif rc == win32event.WAIT_OBJECT_0+1: # Message waiting. if win32gui.PumpWaitingMessages(): raise RuntimeError("We got an unexpected WM_QUIT message!") else: # This wait timed-out. if time.time()-start_time > 30: raise RuntimeError("We timed out waiting for the timers to expire!")
Example #4
Source File: test_engine_natlink_timer.py From dragonfly with GNU Lesser General Public License v3.0 | 5 votes |
def DISABLED_test_natlink_timer_manager(self): return import dragonfly.engines.backend_natlink as backend print(backend.is_engine_available()) engine = backend.get_engine() print(engine) engine.connect() try: print("starting timer...") def callback(): engine._log.error("timer callback") print("timer callback") timer = engine.create_timer(callback, 1) print("timer:", timer) print("starting Luke...") import sys import time import win32gui timeout = time.time() + 3 while time.time() < timeout: print("Luke") sys.stdout.flush() if win32gui.PumpWaitingMessages(): raise RuntimeError("We got an unexpected WM_QUIT message!") time.sleep(1) finally: engine.disconnect() # self.engine.natlink.setTimerCallback(callback, int(sec * 1000)) #---------------------------------------------------------------------------
Example #5
Source File: test_engine_natlink_timer.py From dragonfly with GNU Lesser General Public License v3.0 | 5 votes |
def DISABLED_test_natlink_timer(self): return callback_occurred = False def callback(): callback_occurred = True ticks = 200 import time import natlink natlink.natConnect() try: natlink.setTimerCallback(callback, ticks) # time.sleep(1) import sys import time import win32gui timeout = time.time() + 3 while time.time() < timeout: print("Luke") sys.stdout.flush() if win32gui.PumpWaitingMessages(): raise RuntimeError("We got an unexpected WM_QUIT message!") time.sleep(1) natlink.setTimerCallback(None, 0) print("callback occurred:", callback_occurred) finally: natlink.natDisconnect() #---------------------------------------------------------------------------
Example #6
Source File: test_engine_natlink_timer.py From dragonfly with GNU Lesser General Public License v3.0 | 5 votes |
def DISABLED_test_natlink_timer_manager(self): return import dragonfly.engines.backend_natlink as backend print backend.is_engine_available() engine = backend.get_engine() print engine engine.connect() try: print "starting timer..." def callback(): engine._log.error("timer callback") print "timer callback" timer = engine.create_timer(callback, 1) print "timer:", timer print "starting Luke..." import sys import time import win32gui timeout = time.time() + 3 while time.time() < timeout: print "Luke" sys.stdout.flush() if win32gui.PumpWaitingMessages(): raise RuntimeError, "We got an unexpected WM_QUIT message!" time.sleep(1) finally: engine.disconnect() # self.engine.natlink.setTimerCallback(callback, int(sec * 1000)) #---------------------------------------------------------------------------
Example #7
Source File: test_engine_natlink_timer.py From dragonfly with GNU Lesser General Public License v3.0 | 5 votes |
def DISABLED_test_natlink_timer(self): return callback_occurred = False def callback(): callback_occurred = True ticks = 200 import time import natlink natlink.natConnect() try: natlink.setTimerCallback(callback, ticks) # time.sleep(1) import sys import time import win32gui timeout = time.time() + 3 while time.time() < timeout: print "Luke" sys.stdout.flush() if win32gui.PumpWaitingMessages(): raise RuntimeError, "We got an unexpected WM_QUIT message!" time.sleep(1) natlink.setTimerCallback(None, 0) print "callback occurred:", callback_occurred finally: natlink.natDisconnect() #---------------------------------------------------------------------------
Example #8
Source File: __init__.py From pyrexecd with MIT License | 5 votes |
def idle(self): return not win32gui.PumpWaitingMessages()
Example #9
Source File: win32eventreactor.py From python-for-android with Apache License 2.0 | 5 votes |
def doWaitForMultipleEvents(self, timeout): log.msg(channel='system', event='iteration', reactor=self) if timeout is None: #timeout = INFINITE timeout = 100 else: timeout = int(timeout * 1000) if not (self._events or self._writes): # sleep so we don't suck up CPU time time.sleep(timeout / 1000.0) return canDoMoreWrites = 0 for fd in self._writes.keys(): if log.callWithLogger(fd, self._runWrite, fd): canDoMoreWrites = 1 if canDoMoreWrites: timeout = 0 handles = self._events.keys() or [self.dummyEvent] val = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT | QS_ALLEVENTS) if val == WAIT_TIMEOUT: return elif val == WAIT_OBJECT_0 + len(handles): exit = win32gui.PumpWaitingMessages() if exit: self.callLater(0, self.stop) return elif val >= WAIT_OBJECT_0 and val < WAIT_OBJECT_0 + len(handles): fd, action = self._events[handles[val - WAIT_OBJECT_0]] log.callWithLogger(fd, self._runAction, action, fd)
Example #10
Source File: win32eventreactor.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def doWaitForMultipleEvents(self, timeout, reads=reads, writes=writes): log.msg(channel='system', event='iteration', reactor=self) if timeout is None: #timeout = INFINITE timeout = 100 else: timeout = int(timeout * 1000) if not (events or writes): # sleep so we don't suck up CPU time time.sleep(timeout / 1000.0) return canDoMoreWrites = 0 for fd in writes.keys(): if log.callWithLogger(fd, self._runWrite, fd): canDoMoreWrites = 1 if canDoMoreWrites: timeout = 0 handles = events.keys() or [self.dummyEvent] val = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT | QS_ALLEVENTS) if val == WAIT_TIMEOUT: return elif val == WAIT_OBJECT_0 + len(handles): exit = win32gui.PumpWaitingMessages() if exit: self.callLater(0, self.stop) return elif val >= WAIT_OBJECT_0 and val < WAIT_OBJECT_0 + len(handles): fd, action = events[handles[val - WAIT_OBJECT_0]] log.callWithLogger(fd, self._runAction, action, fd)
Example #11
Source File: console.py From eavatar-me with Apache License 2.0 | 5 votes |
def run(self): while not win32gui.PumpWaitingMessages(): self.shell.process_idle_tasks() time.sleep(0.1)
Example #12
Source File: notice_dlg.py From eavatar-me with Apache License 2.0 | 5 votes |
def run(self): while not win32gui.PumpWaitingMessages(): self.shell.process_idle_tasks() time.sleep(0.1)
Example #13
Source File: win32gui_devicenotify.py From ironpython2 with Apache License 2.0 | 4 votes |
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)
Example #14
Source File: desktopmanager.py From ironpython2 with Apache License 2.0 | 4 votes |
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)