Python win32gui.RegisterWindowMessage() Examples
The following are 8
code examples of win32gui.RegisterWindowMessage().
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
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: win32gui_taskbar.py From ironpython2 with Apache License 2.0 | 6 votes |
def __init__(self): msg_TaskbarRestart = win32gui.RegisterWindowMessage("TaskbarCreated"); message_map = { msg_TaskbarRestart: self.OnRestart, win32con.WM_DESTROY: self.OnDestroy, win32con.WM_COMMAND: self.OnCommand, win32con.WM_USER+20 : self.OnTaskbarNotify, } # Register the Window class. wc = win32gui.WNDCLASS() hinst = wc.hInstance = win32api.GetModuleHandle(None) wc.lpszClassName = "PythonTaskbarDemo" wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW; wc.hCursor = win32api.LoadCursor( 0, win32con.IDC_ARROW ) wc.hbrBackground = win32con.COLOR_WINDOW wc.lpfnWndProc = message_map # could also specify a wndproc. # Don't blow up if class already registered to make testing easier try: classAtom = win32gui.RegisterClass(wc) except win32gui.error, err_info: if err_info.winerror!=winerror.ERROR_CLASS_ALREADY_EXISTS: raise # Create the Window.
Example #2
Source File: testExplorer.py From ironpython2 with Apache License 2.0 | 6 votes |
def TestObjectFromWindow(): # Check we can use ObjectFromLresult to get the COM object from the # HWND - see KB Q249232 # Locating the HWND is different than the KB says... hwnd = win32gui.FindWindow('IEFrame', None) for child_class in ['TabWindowClass', 'Shell DocObject View', 'Internet Explorer_Server']: hwnd = win32gui.FindWindowEx(hwnd, 0, child_class, None) assert hwnd, "Couldn't find '%s'" % (child_class,) # But here is the point - once you have an 'Internet Explorer_Server', # you can send a message and use ObjectFromLresult to get it back. msg = win32gui.RegisterWindowMessage("WM_HTML_GETOBJECT") rc, result = win32gui.SendMessageTimeout(hwnd, msg, 0, 0, win32con.SMTO_ABORTIFHUNG, 1000) ob = pythoncom.ObjectFromLresult(result, pythoncom.IID_IDispatch, 0) doc = Dispatch(ob) # just to prove it works, set the background color of the document. for color in "red green blue orange white".split(): doc.bgColor = color time.sleep(0.2)
Example #3
Source File: __init__.py From pyrexecd with MIT License | 6 votes |
def initialize(klass): WM_RESTART = win32gui.RegisterWindowMessage('TaskbarCreated') klass.WM_NOTIFY = win32con.WM_USER+1 klass.WNDCLASS = win32gui.WNDCLASS() klass.WNDCLASS.hInstance = win32gui.GetModuleHandle(None) klass.WNDCLASS.lpszClassName = 'Py_'+klass.__name__ klass.WNDCLASS.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW; klass.WNDCLASS.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW) klass.WNDCLASS.hIcon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION) klass.WNDCLASS.hbrBackground = win32con.COLOR_WINDOW klass.WNDCLASS.lpfnWndProc = { WM_RESTART: klass._restart, klass.WM_NOTIFY: klass._notify, win32con.WM_CLOSE: klass._close, win32con.WM_DESTROY: klass._destroy, win32con.WM_COMMAND: klass._command, } klass.CLASS_ATOM = win32gui.RegisterClass(klass.WNDCLASS) klass._instance = {} return
Example #4
Source File: shell.py From eavatar-me with Apache License 2.0 | 5 votes |
def __init__(self): super(Shell, self).__init__() msg_taskbar_restart = win32gui.RegisterWindowMessage("TaskbarCreated") self.message_map = {msg_taskbar_restart: self.OnRestart, win32con.WM_DESTROY: self.OnDestroy, win32con.WM_COMMAND: self.OnCommand, win32con.WM_USER + 20: self.OnTaskbarNotify, } self.main_frame = MainFrame(self.message_map) self.status_icon = StatusIcon(self) self.notice_index = -1 # rolling index of topmost notice in the queue self.console = None self.destroyed = False
Example #5
Source File: SysTrayIcon.py From LIFX-Control-Panel with MIT License | 4 votes |
def __init__(self, icon, hover_text, menu_options, on_quit=None, default_menu_index=None, window_class_name=None, ): self.logger = logging.getLogger("root.SysIcon") self.icon = icon self.hover_text = hover_text self.on_quit = on_quit menu_options = menu_options + (('Quit', None, self.QUIT),) self._next_action_id = self.FIRST_ID self.menu_actions_by_id = set() self.menu_options = self._add_ids_to_menu_options(list(menu_options)) self.menu_actions_by_id = dict(self.menu_actions_by_id) del self._next_action_id self.default_menu_index = (default_menu_index or 0) self.window_class_name = window_class_name or "SysTrayIconPy" message_map = {win32gui.RegisterWindowMessage("TaskbarCreated"): self.restart, win32con.WM_DESTROY: self.destroy, win32con.WM_COMMAND: self.command, win32con.WM_USER + 20: self.notify, } # Register the Window class. window_class = win32gui.WNDCLASS() hinst = window_class.hInstance = win32gui.GetModuleHandle(None) window_class.lpszClassName = self.window_class_name window_class.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW; window_class.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW) window_class.hbrBackground = win32con.COLOR_WINDOW window_class.lpfnWndProc = message_map # could also specify a wndproc. classAtom = win32gui.RegisterClass(window_class) # Create the Window. style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU self.hwnd = win32gui.CreateWindow(classAtom, self.window_class_name, style, 0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, 0, 0, hinst, None) win32gui.UpdateWindow(self.hwnd) self.notify_id = None self.refresh_icon() win32gui.PumpMessages()
Example #6
Source File: tray.py From MouseTracks with GNU General Public License v3.0 | 4 votes |
def __init__(self, menu_options, program_name='Python Taskbar', window_name=None): self.logger = logging.getLogger("tray") self.cache = {} self._commands = {'OnMenuOpen': [], 'OnMenuClose': [], 'OnWindowHide': [], 'OnWindowRestore': []} self.program_name = program_name try: self.console_hwnd = WindowHandle(parent=False, console=True) except NameError: self.console_hwnd = None self._refresh_menu(menu_options) if window_name is None: window_name = program_name #Set up callbacks msg_TaskbarRestart = win32gui.RegisterWindowMessage('TaskbarCreated') message_map = { msg_TaskbarRestart: self.OnRestart, win32con.WM_DESTROY: self.OnDestroy, win32con.WM_COMMAND: self.OnCommand, TRAY_EVENT: self.OnTaskbarNotify, } #Register the Window class. wc = win32gui.WNDCLASS() hinst = wc.hInstance = win32api.GetModuleHandle(None) wc.lpszClassName = window_name wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW wc.hCursor = win32api.LoadCursor(0, win32con.IDC_ARROW) wc.hbrBackground = win32con.COLOR_WINDOW wc.lpfnWndProc = message_map # could also specify a wndproc. #Don't blow up if class already registered to make testing easier try: classAtom = win32gui.RegisterClass(wc) except (win32gui.error, err_info): if err_info.winerror!=winerror.ERROR_CLASS_ALREADY_EXISTS: raise #Create the Window. style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU self.hwnd = win32gui.CreateWindow(wc.lpszClassName, window_name, style, \ 0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, \ 0, 0, hinst, None) win32gui.UpdateWindow(self.hwnd) self._set_icon() self.logger.info('Window created.')
Example #7
Source File: systray.py From OpenBazaar-Installer with MIT License | 4 votes |
def __init__(self, icon, hover_text, menu_options, on_quit=None, default_menu_index=None, window_class_name=None, ): self.icon = icon self.hover_text = hover_text self.on_quit = on_quit menu_options = menu_options + (('Quit', None, self.QUIT),) self._next_action_id = self.FIRST_ID self.menu_actions_by_id = set() self.menu_options = self._add_ids_to_menu_options(list(menu_options)) self.menu_actions_by_id = dict(self.menu_actions_by_id) del self._next_action_id self.default_menu_index = (default_menu_index or 0) self.window_class_name = window_class_name or "SysTrayIconPy" message_map = {win32gui.RegisterWindowMessage("TaskbarCreated"): self.restart, win32con.WM_DESTROY: self.destroy, win32con.WM_COMMAND: self.command, win32con.WM_USER + 20: self.notify, } # Register the Window class. window_class = win32gui.WNDCLASS() hinst = window_class.hInstance = win32gui.GetModuleHandle(None) window_class.lpszClassName = self.window_class_name window_class.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW window_class.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW) window_class.hbrBackground = win32con.COLOR_WINDOW window_class.lpfnWndProc = message_map # could also specify a wndproc. classAtom = win32gui.RegisterClass(window_class) # Create the Window. style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU self.hwnd = win32gui.CreateWindow(classAtom, self.window_class_name, style, 0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, 0, 0, hinst, None) win32gui.UpdateWindow(self.hwnd) self.notify_id = None self.refresh_icon() win32gui.PumpMessages()
Example #8
Source File: gui_win.py From ComicStreamer with Apache License 2.0 | 4 votes |
def __init__(self, apiServer): self.apiServer = apiServer self.icon = AppFolders.imagePath("trout.ico") self.hover_text = "ComicStreamer" self.on_quit = self.bye menu_options = ( ('Show ComicStreamer UI', None, self.show), ) menu_options = menu_options + (('Quit', None, self.QUIT),) self._next_action_id = self.FIRST_ID self.menu_actions_by_id = set() self.menu_options = self._add_ids_to_menu_options(list(menu_options)) self.menu_actions_by_id = dict(self.menu_actions_by_id) del self._next_action_id self.default_menu_index = 1 self.window_class_name = "ComicStreamerTrayIcon" message_map = {win32gui.RegisterWindowMessage("TaskbarCreated"): self.restart, win32con.WM_DESTROY: self.destroy, win32con.WM_COMMAND: self.command, win32con.WM_USER+20 : self.notify,} # Register the Window class. window_class = win32gui.WNDCLASS() hinst = window_class.hInstance = win32gui.GetModuleHandle(None) window_class.lpszClassName = self.window_class_name window_class.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW; window_class.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW) window_class.hbrBackground = win32con.COLOR_WINDOW window_class.lpfnWndProc = message_map # could also specify a wndproc. classAtom = win32gui.RegisterClass(window_class) # Create the Window. style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU self.hwnd = win32gui.CreateWindow(classAtom, self.window_class_name, style, 0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, 0, 0, hinst, None) win32gui.UpdateWindow(self.hwnd) self.notify_id = None self.refresh_icon()