def hotKeyPrintText(self, key, text, pressEnter=False, useKeyDelay=True): Validator.notEmpty(text, "hotKeyPrintText on %s button" % Parser.parseHotKey(key)) self.key_bindings.append("\n%s::" % Parser.parseHotKey(key)) if useKeyDelay: self.key_bindings.append(setKeyDelay(text)) self.key_bindings.append("SendRaw "+ text) if pressEnter: self.key_bindings.append("Send {enter}") self.key_bindings.append("return")
def hotKeyPrintText(self, key, text, pressEnter=False, useKeyDelay=True): Validator.notEmpty( text, "hotKeyPrintText on %s button" % Parser.parseHotKey(key)) self.key_bindings.append("\n%s::" % Parser.parseHotKey(key)) if useKeyDelay: self.key_bindings.append(setKeyDelay(text)) self.key_bindings.append("SendRaw " + text) if pressEnter: self.key_bindings.append("Send {enter}") self.key_bindings.append("return")
def setHotKeyAction(self, key, action, data): if action == TOKEN.HK_PRINT: self.hotKeyPrintText(key, data, pressEnter=False, useKeyDelay=False) elif action == TOKEN.HK_PASTE: #TODO will be implemented later, adding stub now self.hotKeyPrintText(key, data, pressEnter=False, useKeyDelay=False) elif action == TOKEN.HK_WRAP: # output = data.replace(TOKEN.SELECTED_TEXT, action) #TODO create new implementation with unlimited usages of [SELECTION] if len(data.split(TOKEN.SELECTED_TEXT)) != 2: print("Split %s length !=2 when parsing line: %s" % (TOKEN.SELECTED_TEXT, data)) return (textLeft, textRight) = data.split(TOKEN.SELECTED_TEXT) self.hotKeyWrapSelectedText(key, textLeft, textRight, pressEnter=False) elif action == TOKEN.HK_INCLUDE_FILE: if not key == TOKEN.HK_DEFINED_IN_FILE: self.key_bindings.append("\n%s::" % Parser.parseHotKey(key)) self.key_bindings.append(includeFile(data))
def hotKeyWrapSelectedText(self, key, textLeft, textRight, pressEnter=False): Validator.notEmpty( textLeft, "hotKeyWrapSelectedText <textLeft> on %s button" % Parser.parseHotKey(key)) Validator.notEmpty( textRight, "hotKeyWrapSelectedText <textRight> on %s button" % Parser.parseHotKey(key)) self.key_bindings.append("\n%s::" % Parser.parseHotKey(key)) self.key_bindings.append(""" ClipSaved := ClipboardAll Clipboard = Send ^x ClipWait 1 SendInput %s Send ^v SendInput %s Clipboard := ClipSaved ClipSaved = Return """ % (textLeft, textRight))
def hotKeyWrapSelectedText(self, key, textLeft, textRight, pressEnter=False): Validator.notEmpty(textLeft, "hotKeyWrapSelectedText <textLeft> on %s button" % Parser.parseHotKey(key)) Validator.notEmpty(textRight, "hotKeyWrapSelectedText <textRight> on %s button" % Parser.parseHotKey(key)) self.key_bindings.append("\n%s::" % Parser.parseHotKey(key)) self.key_bindings.append(""" ClipSaved := ClipboardAll Clipboard = Send ^x ClipWait 1 SendInput %s Send ^v SendInput %s Clipboard := ClipSaved ClipSaved = Return """ % (textLeft, textRight))
def setHotKeyAction(self, key, action, data): if action == TOKEN.HK_PRINT: self.hotKeyPrintText(key, data, pressEnter=False, useKeyDelay=False) elif action == TOKEN.HK_PASTE: #TODO will be implemented later, adding stub now self.hotKeyPrintText(key, data, pressEnter=False, useKeyDelay=False) elif action == TOKEN.HK_WRAP: # output = data.replace(TOKEN.SELECTED_TEXT, action) #TODO create new implementation with unlimited usages of [SELECTION] if len(data.split(TOKEN.SELECTED_TEXT)) != 2: print("Split %s length !=2 when parsing line: %s" % (TOKEN.SELECTED_TEXT ,data)) return (textLeft, textRight) = data.split(TOKEN.SELECTED_TEXT) self.hotKeyWrapSelectedText(key, textLeft, textRight, pressEnter=False) elif action == TOKEN.HK_INCLUDE_FILE: if not key == TOKEN.HK_DEFINED_IN_FILE: self.key_bindings.append("\n%s::" % Parser.parseHotKey(key)) self.key_bindings.append(includeFile(data))
def assignMenuHotKey(self): self.builder.menu_tree.append( "return ; End of menu tree definition section.") self.builder.menu_key_bindings.append( "%s::Menu, %s, Show ; i.e. press the Win-%s hotkey to show the menu.\n" % (Parser.parseHotKey(self.key), self.name, self.key))
def assignMenuHotKey(self): self.builder.menu_tree.append("return ; End of menu tree definition section.") self.builder.menu_key_bindings.append("%s::Menu, %s, Show ; i.e. press the Win-%s hotkey to show the menu.\n" % (Parser.parseHotKey(self.key), self.name, self.key))