def test_gcalctool1(self): self.p = EasyProcess('gnome-calculator').start() self.wait() focus_wnd() send_key('ctrl+q') time.sleep(1) # img_debug(grab(), 'ctrl+q') self.assertFalse(getbbox(grab()))
def discover_buttons(grid=30): ''' try to get buttons by tab order ''' tab_ls = tab_rectangles() if not len(tab_ls): log.debug('no tab order on window -> full hover test') # slow, no tab order return hover.active_rectangles(grid=grid) img_orig = focus_wnd() ls = [] for x in tab_ls: bbox = hover.is_point_active(img_orig, x.center) if bbox: ls += [x] img_log_rects(img_orig, ls, 'img_orig') log.debug('buttons found:%s', ls) return ls
def tab_rectangles(): ''' Return rectangles found by sending TAB button events. Does not work if other parts of screen are changing (e.g. blinking cursor) :rtype: rectangles list ''' ls = [] img_orig = focus_wnd() im1 = img_orig while 1: send_key('\t') im2 = pyscreenshot.grab() img_log(im1, 'im1') img_log(im2, 'im2') boxes = tab_rect_pair(im1, im2) if not boxes: return [] if len(ls): if len(boxes) == 2: # TODO: implement almost_equal() assert boxes[0] == ls[-1] if boxes[-1] in ls: break ls += [boxes[-1]] else: # first ls += boxes im1 = im2 img_log_rects(img_orig, ls, 'img_orig') log.debug('rectangles found:%s', ls) return ls