def onTextBegin(self, moduleInfo): """at start of each utterance, like gotBegin for command grammars """ hndle = moduleInfo[2] if hndle != self.prevHndle: self.prevHndle = hndle if self.dctactive: dct = self.dictObj dct.deactivate() self.dctactive = 0 prog, title, topchild, hndle = unimacroutils.getProgInfo( moduleInfo) print('changing app to: "%s", %s' % (prog, hndle)) self.app, self.ctrl = None, None if prog in self.WindowsParameters: self.getEditControl(prog, hndle) if self.ctrl: print('got edit control for "%s": %s' % (prog, self.ctrl)) self.app = prog else: print('no edit control found for "%s"' % prog) if self.ctrl is None: return if not self.dctactive: dct = self.dictObj print('activate dictObj to %s' % self.ctrl) dct.activate(self.ctrl) self.dctactive = 1 self.updateState()
def gotBegin(self, moduleInfo): if self.checkForChanges: self.checkInifile() if self.prevModInfo == moduleInfo: return # changing sets, as moduleInfo changed ## if not moduleInfo[0]: # no valid module info, do nothing ## print 'no module info, skipping' ## return # if window changes reset base: self.maxBase = 0 self.base = 0 progInfo = unimacroutils.getProgInfo(modInfo=moduleInfo) if unimacroutils.matchWindow(self.ignore, progInfo=progInfo): ## print 'progInfo in ignore, skipping: %s'% self.ignore return if self.windowPolicy(moduleInfo, progInfo): if self.mode != 'active': self.activateAll() self.mode = 'active' else: pass ## print '%s, remains active'% self.getName() else: if self.mode != 'inactive': ## print '%s: non matching window deactivate: %s'% \ ## (self.getName(), moduleInfo[1]) self.deactivateAll() self.mode = 'inactive' else: pass ## print '%s, remains inactive'% self.getName() self.prevModInfo = moduleInfo self.progInfo = progInfo
def gotBegin(self, moduleInfo): if self.checkForChanges: self.checkInifile() if self.prevModInfo != moduleInfo: progInfo = unimacroutils.getProgInfo(modInfo=moduleInfo) self.prevModInfo = moduleInfo self.cancelMode() self.prog = progInfo.prog if self.prog == 'calc': self.activeSet = None else: if self.exclusive: self.activeSet = None # reinitialize non exclusive if self.inCalculation: if self.prog != 'calc': if not self.activeSet == self.continueRules: self.activeSet = copy.copy(self.continueRules) self.exclusive = 1 self.activateSet(self.activeSet, exclusive=self.exclusive) print("calculation, exclusiveRules activated") else: if self.prog == 'calc': if not self.activeSet == self.calcRules: self.activeSet = copy.copy(self.calcRules) self.exclusive = 1 self.activateSet(self.activeSet, exclusive=self.exclusive) print("calc, exclusive rules activated") else: if not self.activeSet == self.normalRules: if self.activeSet: print("calculation, activate normalRules again") self.activeSet = copy.copy(self.normalRules) self.exclusive = 0 self.activateSet(self.activeSet, exclusive=self.exclusive)
def gotBegin(self, moduleInfo): if not language: return if self.checkForChanges: self.prevHandle = None winHandle = moduleInfo[2] if not winHandle: print('no window handle in %s' % self.name) return if self.prevHandle == winHandle: return self.prevHandle = winHandle progInfo = unimacroutils.getProgInfo(moduleInfo) # print('progInfo: %s'% repr(progInfo)) prog = progInfo.prog chromiumBrowsers = {'chromium', 'chrome', 'msedge', 'safari', 'brave'} if prog in chromiumBrowsers: if progInfo.topchild == 'child': print('in child window, the clickbyvoice window?') if self.checkForChanges: print('_clickbyvoice (%s), prog: %s, checking the inifile' % (self.name, prog)) self.checkInifile() self.switchOnOrOff(window=winHandle) if not self.isActive == winHandle: print("activate _clickbyvoice, %s, %s" % (prog, winHandle)) self.activateAll(window=winHandle) self.isActive = winHandle else: if self.isActive: print("deactivate _clickbyvoice") self.deactivateAll() self.isActive = False
def windowPolicy(self, modInfo, progInfo=None): progInfo = progInfo or unimacroutils.getProgInfo(modInfo) ## print 'window policy------progInfo: ', `progInfo` if unimacroutils.matchWindow(self.activateRules, progInfo=progInfo): ## print 'matching activate: %s'% self.activateRules if not unimacroutils.matchWindow(self.deactivateRules, progInfo=progInfo): return 1
def test_matchModule(self): """check if dragonpad is reported as top window and the open dialog as child window behaviour changed in python version 2.3.4!! """ progInfo = unimacroutils.getProgInfo() self.log("progInfo: %s" % repr(progInfo)) actions.doAction("LW") ## changed in 2013 from 3 to 4 items: self.assert_equal(4, len(progInfo), "progInfo should be tuple of 4") self.assert_equal(u'top', progInfo[2], "DragonPad should be a top window") actions.doAction("<<fileopen>>") progInfo = unimacroutils.getProgInfo() actions.doAction("{esc}") self.assert_equal(4, len(progInfo), "progInfo should be tuple of 4") self.assert_equal(u'child', progInfo[2], "DragonPad open dialog should be a child window")
def getInputcontrol(self): """get the Click by Voice input control""" keystroke("{shift+ctrl+space}") unimacroutils.Wait() ## longer: unimacroutils.Wait(visiblePause) for i in range(10): progInfo = unimacroutils.getProgInfo() if progInfo.topchild == 'child': if i: print('found input window after %s steps' % i) break unimacroutils.Wait() else: print("_clickbyvoice failed to reach input window") # print("found input window of clickbyvoice") unimacroutils.visibleWait()
def windowPolicy(self, modInfo=None, progInfo=None): progInfo = progInfo or unimacroutils.getProgInfo(modInfo) #print 'window policy------progInfo: %s'% repr(progInfo) #print 'deactivaterules: %s'% self.deactivateRules #print 'activaterules: %s'% self.activateRules modeSet = [] for mode in self.modes: if unimacroutils.matchWindow(self.modes[mode], progInfo=progInfo): modeSet.append(mode) self.modeSet = set(modeSet) if modeSet: return tuple(modeSet) if unimacroutils.matchWindow(self.activateRules, progInfo=progInfo): if unimacroutils.matchWindow(self.deactivateRules, progInfo=progInfo): return 'inactive' return 'active' else: return 'inactive'
def gotBegin(self, moduleInfo): winHandle = moduleInfo[2] if self.prevHandle == winHandle: return self.prevHandle = winHandle if moduleInfo[0].lower().find( 'frescobaldi.exe') > 0 and unimacroutils.isTopWindow( moduleInfo[2]): if self.frescobaldi is None: progInfo = unimacroutils.getProgInfo(moduleInfo) self.frescobaldi = actions.get_instance_from_progInfo(progInfo) if not self.frescobaldi: raise Exception( "frescobaldi, cannot get frescobaldi actions module") if self.checkForChanges: #print 'grammar frescobaldi (%s) checking the inifile'% self.name self.checkInifile() self.switchOnOrOff() elif self.isActive(): self.deactivateAll()
def gotBegin(self, moduleInfo): winHandle = moduleInfo[2] if self.prevHandle == winHandle: if not self.isActive(): return else: self.prevHandle = winHandle if unimacroutils.matchModule('excel', modInfo=moduleInfo): #print 'activate firefox %s mode'% mode if self.checkForChanges: print('excel (%s), checking the inifile' % self.name) self.checkInifile() self.switchOnOrOff() elif self.isActive(): #print 'deactivate Excel %s mode'% mode self.deactivateAll() if self.excel: self.excel.disconnect() self.excel = None return if self.isActive(): # refreshes current position now as well: progInfo = unimacroutils.getProgInfo(moduleInfo) if self.excel is None: self.excel = actions.get_instance_from_progInfo(progInfo) if self.excel.app: print('excel.app: %s' % self.excel.app) print('Workbooks: %s' % self.excel.app.Workbooks.Count) else: print('no instance for this Excel object available') self.deactivateAll() return res = self.excel.checkForChanges(progInfo) #print 'res from changes: %s'% res if res: self.refreshExcelSettings(res) self.printPositions('from gotBegin')
def gotBegin(self, moduleInfo): if self.checkForChanges: self.checkInifile() self.progInfo = unimacroutils.getProgInfo(moduleInfo)
def gotBegin(self, moduleInfo): if self.checkForChanges: if self.checkInifile(): self.resetAllVars() if self.prevModule == moduleInfo: return progInfo = unimacroutils.getProgInfo(moduleInfo) self.isIgnored = 0 if self.ignore and unimacroutils.matchWindow(self.ignore, progInfo=progInfo): self.isIgnored = 1 return mode = self.windowPolicy(progInfo=progInfo) if mode == self.prevMode: return ## print 'keystrokes, new mode: ', mode if self.prevMode == 'inactive': self.activateAll() self.prevMode = mode ini = self.ini #print 'do keystrokes for mode: %s'% repr(mode) if mode == 'inactive': print('%s: deactivate: %s' % (self.GetName(), mode)) self.deactivateAll() self.cancelMode() self.resetAllVars() return elif mode == 'active': repkeySections = ['repkey'] norepkeySections = ['norepkey'] # print 'activate "default mode" keystrokes' ## print '%s, mode: %s, repkeySections: %s, norepkeySections: %s'% \ ## (self.GetName(), mode, self.repkeySections, self.norepkeySections) else: # print 'activate keystrokes with mode: %s'% repr(mode) # self.modeSet is set of modestrings being active: wantExclusive = self.modeSet & self.exclusiveModes # both a set if wantExclusive: print('make keystokes mode exclusive: %s' % wantExclusive) self.setExclusive(1) #if repkeySections = self.ini.getSectionsWithPrefix('repkey', mode) repkeySections.append('repkey') norepkeySections = self.ini.getSectionsWithPrefix('norepkey', mode) norepkeySections.append('norepkey') #print '%s, mode: %s, repkeySections: %s, norepkeySections: %s'% \ # (self.GetName(), mode, repkeySections, norepkeySections) if repkeySections != self.repkeySections: L = ini.get(repkeySections) self.setList('repkey', L) self.repkeySections = repkeySections[:] self.repkeyList = L[:] if norepkeySections != self.norepkeySections: L = ini.get(norepkeySections) self.setList('norepkey', L) self.norepkeySections = norepkeySections[:] self.norepkeyList = L[:]