def setup(self, test): self._registry = pyatspi.Registry() print self._path self._desktop = self._registry.getDesktop(0) self._root = pyatspi.findDescendant( self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole( ) == pyatspi.ROLE_WINDOW)
def setup(self, test): self._registry = pyatspi.Registry() self._desktop = self._registry.getDesktop(0) self._root = pyatspi.findDescendant( self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole( ) == pyatspi.ROLE_APPLICATION) self._rset = self._root.getRelationSet() test.assertEqual( len(self._rset), 4, "Num relations expected %d, recieved %d" % (4, len(self._rset)))
def setup(self, test): self._registry = pyatspi.Registry() import time self._desktop = self._registry.getDesktop(0) print("--desktop len", len(self._desktop)) for i in self._desktop: try: print("-- object",i,i.getRole()) except: pass self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_APPLICATION) print("--root", self._root)
def argument_parser(self): opts = [] args = [] try: opts, args = getopt.getopt(sys.argv[1:],\ "ahxql:s:",["applications","help","xml","quiet","log=","source="]) except getopt.GetoptError: self.help() for o, a in opts: if o in ("-q", "--quiet"): Settings.is_quiet = True for o, a in opts: if o in ("-h", "--help"): self.help() abort(0) if o in ("-a", "--applications"): self.list_apps() abort(0) if o in ("-l", "--log"): Settings.log_path = a if o in ("-x", "--xml"): Settings.xml_format = True if len(args) < 1: output("You must specify an application to monitor.") self.help() abort(2) reg = pyatspi.Registry() desktop = reg.getDesktop(0) try: desktop.queryTable() except NotImplementedError: pass Settings.source_apps = args[0:] if not Settings.xml_format: apps = [app.name for app in desktop if app is not None] for source_app in Settings.source_apps: if source_app not in apps: output( "The app '%s' was not found on the desktop now, so waiting for it to appear..." % source_app)
# Prints the entire f***ing desktop tree import pyatspi # get the Registry singleton reg = pyatspi.Registry() # get desktop desktop = reg.getDesktop(0) def printAndRecurse(elt, indents=2): for (i, child) in enumerate(elt): print(' ' * (indents + 2)), i, child printAndRecurse(child, indents + 2) for app in desktop: if app: print app printAndRecurse(app)
def point(self, x, y): # From dogtail 9.9.0 which isn't widely distributed yet pyatspi.Registry().generateMouseEvent(x, y, 'abs')
def releaseKey(self, keyName): # From dogtail 9.9.0 which isn't widely distributed yet code = dogtail.rawinput.keyNameToKeyCode(keyName) pyatspi.Registry().generateKeyboardEvent(code, None, pyatspi.KEY_RELEASE)
import time import pyatspi reg = pyatspi.Registry() # get the Registry singleton def get_ms_since_epoch(): milliseconds_since_epoch = int(time.time() * 1000) return milliseconds_since_epoch def mouseEventHandler(event): xCoord = int(event.detail1) yCoord = int(event.detail2) print xCoord, yCoord, dir(event) reg.registerEventListener(mouseEventHandler, 'mouse:button:2p') try: pyatspi.Registry.start() except KeyboardInterrupt: pass finally: pyatspi.Registry.stop()
def setup(self, test): self._registry = pyatspi.Registry() self._desktop = self._registry.getDesktop(0)