How to use the comtypes.client.GetEvents function in comtypes

To help you get started, we’ve selected a few comtypes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nateshmbhat / pyttsx3 / pyttsx3 / drivers / sapi5.py View on Github external
def __init__(self, proxy):
        self._tts = comtypes.client.CreateObject('SAPI.SPVoice')
        # all events
        self._tts.EventInterests = 33790
        self._event_sink = SAPI5DriverEventSink()
        self._event_sink.setDriver(weakref.proxy(self))
        self._advise = comtypes.client.GetEvents(self._tts, self._event_sink)
        self._proxy = proxy
        self._looping = False
        self._speaking = False
        self._stopping = False
        # initial rate
        self._rateWpm = 200
        self.setProperty('voice', self.getProperty('voice'))
github wxWidgets / wxPython-Classic / wx / lib / activex.py View on Github external
def AddEventSink(self, sink, interface=None):
        """
        Add a new target to search for method names that match the COM
        Event names.
        """
        self._evt_connections.append(cc.GetEvents(self._ax, sink, interface))
github enthought / comtypes / comtypes / client / _events.py View on Github external
def ShowEvents(source, interface=None):
    """Receive COM events from 'source'.  A special event sink will be
    used that first prints the names of events that are found in the
    outgoing interface, and will also print out the events when they
    are fired.
    """
    return comtypes.client.GetEvents(source, sink=EventDumper(), interface=interface)
github r0x0r / pywebview / webview / win32.py View on Github external
atl_height = self.height - self.scrollbar_height - NON_RESIZEABLE_OFFSET * 2
        else:
            atl_width = self.width - self.scrollbar_width
            atl_height = self.height - self.scrollbar_height - VERTICAL_SCROLLBAR_OFFSET

        self.atlhwnd = win32gui.CreateWindow("AtlAxWin", "about:blank",
                                             win32con.WS_CHILD | win32con.WS_HSCROLL | win32con.WS_VSCROLL,
                                             0, 0, atl_width, atl_height, self.hwnd, None, hInstance, None)

        # COM voodoo
        pBrowserUnk = POINTER(IUnknown)()
        _atl.AtlAxGetControl(self.atlhwnd, byref(pBrowserUnk))
        self.browser = wrap(pBrowserUnk)
        self.browser.RegisterAsBrowser = True
        self.browser.AddRef()
        self.conn = GetEvents(self.browser, sink=self)
github nvaccess / nvda / source / virtualBuffers_old / MSHTML.py View on Github external
info=self.fieldInfoTemplate.copy()
		info["node"]=domNode
		info['parent']=parentID
		info['range']=[position,position]
		children=[]
		if isinstance(domNode,comInterfaces.MSHTML.DispHTMLFrameElement) or nodeName=="IFRAME":
			try:
				children.append(domNode.contentWindow.document)
			except:
				pass
		elif isinstance(domNode,comInterfaces.MSHTML.DispHTMLDocument):
			try:
				comtypes.client.ReleaseEvents(domNode,self.domEventsObject,interface=comInterfaces.MSHTML.HTMLDocumentEvents2)
			except:
				pass
			self._comEvents=comtypes.client.GetEvents(domNode,self.domEventsObject,interface=comInterfaces.MSHTML.HTMLDocumentEvents2)
			children.append(domNode.body)
		else:
			child=domNode.firstChild
			while child:
				children.append(child)
				try:
					child=child.nextSibling
				except:
					child=None
		info['children']=filter(lambda x: x,[self.getDomNodeID(x) for x in children])
		text=""
		if nodeName=="#text":
			data=domNode.data
			if data and not data.isspace():
				text=data
		elif isinstance(domNode,comInterfaces.MSHTML.DispHTMLFrameElement) or nodeName=="IFRAME":
github nvaccess / nvda / source / virtualBuffers_old / MSHTML.py View on Github external
def __init__(self,NVDAObject):
		#Create a html document com pointer and point it to the com object we receive from the internet explorer_server window
		#domPointer=ctypes.POINTER(comInterfaces.MSHTML.DispHTMLDocument)()
		domPointer=ctypes.POINTER(comtypes.automation.IDispatch)()
		wm=winUser.registerWindowMessage(u'WM_HTML_GETOBJECT')
		lresult=winUser.sendMessage(NVDAObject.windowHandle,wm,0,0)
		ctypes.windll.oleacc.ObjectFromLresult(lresult,ctypes.byref(domPointer._iid_),0,ctypes.byref(domPointer))
		self.dom=comtypes.client.wrap(domPointer)
		virtualBuffer.__init__(self,NVDAObject)
		#Set up events for the document, plus any sub frames
		self.domEventsObject=self.domEventsType(self)
		self._comEvents=comtypes.client.GetEvents(self.dom,self.domEventsObject,interface=comInterfaces.MSHTML.HTMLDocumentEvents2)
		if self.isDocumentComplete():
			self.loadDocument()
github nvaccess / nvda / source / synthDrivers / sapi5.py View on Github external
def _initTts(self, voice=None):
		self.tts=comtypes.client.CreateObject(self.COM_CLASS)
		if voice:
			# #749: It seems that SAPI 5 doesn't reset the audio parameters when the voice is changed,
			# but only when the audio output is changed.
			# Therefore, set the voice before setting the audio output.
			# Otherwise, we will get poor speech quality in some cases.
			self.tts.voice = voice
		outputDeviceID=nvwave.outputDeviceNameToID(config.conf["speech"]["outputDevice"], True)
		if outputDeviceID>=0:
			self.tts.audioOutput=self.tts.getAudioOutputs()[outputDeviceID]
		self._eventsConnection = comtypes.client.GetEvents(self.tts, SapiSink(weakref.ref(self)))
		self.tts.EventInterests = constants.SVEBookmark | constants.SVEEndInputStream
		from comInterfaces.SpeechLib import ISpAudio
		try:
			self.ttsAudioStream=self.tts.audioOutputStream.QueryInterface(ISpAudio)
		except COMError:
			log.debugWarning("SAPI5 voice does not support ISPAudio") 
			self.ttsAudioStream=None