Advertisement
joanmarie

skype tester

Apr 10th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import pyatspi
  4.  
  5. def listener(e):
  6.     if not e.detail1:
  7.         return
  8.  
  9.     obj = e.source
  10.     if not obj.getRole() == pyatspi.ROLE_TABLE_CELL:
  11.         return
  12.  
  13.     isTable = lambda x: 'Table' in pyatspi.utils.listInterfaces(x)
  14.     parentTable = pyatspi.utils.findAncestor(obj, isTable)
  15.     if not parentTable:
  16.         print 'table not found'
  17.         return
  18.  
  19.     iTable = parentTable.queryTable()
  20.  
  21.     contact = obj.name
  22.     index = obj.getIndexInParent()
  23.     cRow = iTable.getRowAtIndex(index)
  24.     cCol = iTable.getColumnAtIndex(index)
  25.     print '\nFocused Contact: %s (row: %s col: %s)' % (contact, cRow, cCol)
  26.     print 'Contact at (%s, %s): %s' % (cRow, cCol, iTable.getAccessibleAt(cRow, cCol))
  27.     print 'All Contacts:'
  28.     for row in range(iTable.nRows):
  29.         # contact name seems to be in the first column
  30.         print '   row %i: %s' % (row, iTable.getAccessibleAt(row, 0).name)
  31.  
  32. pyatspi.Registry.registerEventListener(listener, 'object:state-changed:focused')
  33. pyatspi.Registry.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement