コード例 #1
0
ファイル: jumpToWindow.py プロジェクト: ctoth/jumpToWindow
	def find(self, text):
		"""Find a window with the supplied text in its title.
		If the text isn't found in any title, search the text of consoles."""
		consoles = set()
		text = text.lower()
		for c in api.getDesktopObject().children:
			name = c.name
			if name is None:
				continue
			if text in name.lower():
				focus(c.windowHandle)
				return
			elif c.windowClassName == u'ConsoleWindowClass':
				consoles.add(c)

		#We didn't find the search text in the title, start searching consoles
		current_console = winConsoleHandler.consoleObject
		# If our current console is the one with the text in it, presumably we want another one, and if one isn't found, we'll refocus anyway
		if current_console is not None:
			consoles.remove(current_console)
		for console in consoles:
			#We assume this can't fail
			console_text = get_console_text(console)
			if text in console_text.lower():
				focus(console.windowHandle)
				return
		else: #No consoles found
			if current_console:
				winConsoleHandler.connectConsole(current_console)
				if current_console == api.getFocusObject():
					current_console.startMonitoring() #Keep echoing if we didn't switch
		tones.beep(300, 150)
コード例 #2
0
	def event_becomeNavigatorObject(self):
		if winConsoleHandler.consoleObject is not self:
			if winConsoleHandler.consoleObject:
				winConsoleHandler.disconnectConsole()
			winConsoleHandler.connectConsole(self)
			if self == api.getFocusObject():
				# The user is returning to the focus object with object navigation.
				# The focused console should always be monitored if possible.
				self.startMonitoring()
		super(WinConsole,self).event_becomeNavigatorObject()
コード例 #3
0
ファイル: jumpToWindow.py プロジェクト: ctoth/jumpToWindow
def get_console_text(console):
	"""Gets the text of a console. The caller is responsible for
	reconnecting the current console if needed."""
	child = [child for child in console.children if child.role == controlTypes.ROLE_TERMINAL][0]
	if winConsoleHandler.consoleObject is not child: #We need to connect it
		if winConsoleHandler.consoleObject:
			winConsoleHandler.disconnectConsole()
		winConsoleHandler.connectConsole(child)
	console_text = get_text(child)
	if winConsoleHandler.consoleObject:
		winConsoleHandler.disconnectConsole()
	return console_text
コード例 #4
0
		def reconnect():
			if api.getFocusObject()==self:
				winConsoleHandler.connectConsole(self)
				self.startMonitoring()
コード例 #5
0
	def event_gainFocus(self):
		if winConsoleHandler.consoleObject is not self:
			if winConsoleHandler.consoleObject:
				winConsoleHandler.disconnectConsole()
			winConsoleHandler.connectConsole(self)
		super(WinConsole, self).event_gainFocus()