def subrule_closemultiple(self, words): """close (all|other) | (all|other) close """ # note the grammar alternatives, eg in Dutch the translation of # all close (alles sluiten) is more convenient. if not self.lastTaskCount: print( '_tasks, close all | close multiple only works with a numbered task' ) return all = self.hasCommon(words, "all") multiple = self.hasCommon(words, "multiple") if all: action("MP 2, 0, 0, right; VW; {up}{enter}; VW") self.gotoTask("back") elif multiple: # close as long as special stacked window is found mousePos = natqh.getMousePosition() if mousePos is None: raise ValueError("could not get mouse position") x, y = mousePos className = natqh.getClassName() wNum = -1 # last window of stacked windows... #print 'tasks, subtask: %s'% wNum while className == "TaskListThumbnailWnd": #print 'got subtask, alternative window: %s'% words self.doAlternativeClick(className, wNum) action("<<windowclose>>") action("VW; MP 0, %s, %s" % mousePos) className = natqh.getClassName() self.gotoTask(self.lastTaskCount) if self.centerMouse: natqh.doMouse(1, 5, 0.3, 0.3, 0, 0)
def tttest_getPositions(self): """test setting and getting positions in all possible ways use action RMP to go to the wanted position. then each time get a position (absolute/relative, absorrel, screen, active window or client area (0, 1, 5), and relative to one of the corners (0, 1, 2, 3)) setting it again and see if same position is found get with: getMousePosition set with: doMouse """ #absorrel = 0 # absolute #which = 0 # whole screen #corner = 0 # top left action("RMP(5, 0.3, 0.4, noclick)" ) # relative in foreground window, tune to your testing! initialPosition = natlink.getCursorPos() for absorrel in (0, 1): for which in (0, 1, 5): for cornerPos in range(4): #absorrel, which, cornerPos = 1, 0, 0 #absorrel = 1 # each test, little shifting for relative allowed if absorrel: epsilon = 0 # relative, position may shift a bit... else: epsilon = 0 # absolute, caculations must fit if absorrel == 0 and which == 0 and cornerPos > 0: print 'invalid combination to test: absorrel: %s, which: %s, cornerPos: %s' % ( absorrel, which, cornerPos) continue initialPosition = natlink.getCursorPos() mousePos = natlinkutilsqh.getMousePosition( absorrel, which, cornerPos) if mousePos is None: self.fail( 'getMousePosition in test suite should not result in None (absorrel: %s, which: %s, cornerPos: %s)' % (absorrel, which, cornerPos)) x, y = mousePos natlinkutilsqh.doMouse(absorrel, which, x, y, mouse="noclick") finalPosition = natlink.getCursorPos() log('command: %s, %s, %s, %s, initial: %s, final: %s' % (absorrel, which, x, y, repr(initialPosition), repr(finalPosition))) self.assert_equal( initialPosition, finalPosition, "position of mouse after simple action should be the same\n" "absorrel: %s, which: %s, cornerPos: %s" % (absorrel, which, cornerPos), epsilon=epsilon)
def tttest_getOutsideWindow(self): """try to position on the taskbar and get the position """ action("RMP(5, 1, 0.5, noclick)") # relative in foreground window, tune to your testing! action("MP(2, 500, 0, noclick)") # move a bit to the right initialPosition = natlink.getCursorPos() mousePos = natlinkutilsqh.getMousePosition() # abs, screen, corner not relevant if mousePos is None: self.fail("could not get mouse position") x, y = mousePos absorrel, which = 0, 0 natlinkutilsqh.doMouse(absorrel, which, x, y, mouse="noclick") finalPosition = natlink.getCursorPos() log('command outside window(?): %s, %s, %s, %s, initial: %s, final: %s'% (absorrel, which, x, y, repr(initialPosition), repr(finalPosition))) self.assert_equal(initialPosition, finalPosition, "position of mouse after move outside the current window should be the same\n" "absorrel: %s, which: %s"% (absorrel, which))