import mode import keyboard import words import programs release = Key("shift:up, ctrl:up, alt:up") class GlobalCommandRule(MappingRule): mapping = { "release mode": Function(lambda: mode.MultiMode.deactivate_all()), } alternatives = [] alternatives.append(RuleRef(rule=GlobalCommandRule())) alternatives.append(RuleRef(rule=keyboard.KeystrokeRule())) alternatives.append(RuleRef(rule=words.FormatRule())) alternatives.append(RuleRef(rule=words.ReFormatRule())) alternatives.append(RuleRef(rule=words.NopeFormatRule())) alternatives.append(RuleRef(rule=words.PhraseFormatRule())) alternatives.append(RuleRef(rule=programs.ProgramsRule())) root_action = Alternative(alternatives) sequence = Repetition(root_action, min=1, max=16, name="sequence") class RepeatRule(CompoundRule): # Here we define this rule's spoken-form and special elements. spec = "<sequence> [[[and] repeat [that]] <n> times]" extras = [ sequence, # Sequence of actions defined above. IntegerRef("n", 1, 100), # Times to repeat the sequence.
from natlink import setMicState from aenea import * import keyboard import words release = Key("shift:up, ctrl:up, alt:up, win:up") dictation = RuleRef(name="dictation", rule=words.FormatRule()) command_list = [] command_list.append(RuleRef(rule=keyboard.KeystrokeRule())) command_list.append(dictation) commands = Alternative(command_list, name="commands") sequence = Repetition(commands, min=1, max=10, name="sequence") class RepeatRule(CompoundRule): # Here we define this rule's spoken-form and special elements. spec = ("[<sequence>] " "[terminal <dictation>] " "[<n> times] ") extras = [ sequence, # Sequence of actions defined above. dictation,