def toggleText(text): prevText = text text = text.upper() if text == prevText: text = text.lower() setClipboardData(text) sendPasteKey() sendLefts(len(text), True)
def urlShortener(text): from urllib2 import Request, urlopen, URLError request = Request('http://is.gd/api.php?longurl=' + text.strip()) try: response = urlopen(request) shortURL = response.read() setClipboardData(shortURL) sendPasteKey() except URLError: pass
def hyphenateText(text): setClipboardData(text.replace(" ", "-")) sendPasteKey()
def hashtagText(text): import re textAlphaOnly = re.sub(r'\W+', '', text) hashtag = "#" + textAlphaOnly.lower() setClipboardData(hashtag) sendPasteKey()
def twiddle(text): setClipboardData(text[::-1]) sendPasteKey()
def surroundWithTags(beginTag, endTag, text): trimmer = re.compile("^(\s*)(.*[^\s])(\s*)$") matches = trimmer.match(text) setClipboardData(matches.group(1) + beginTag + matches.group(2) + endTag + matches.group(3)) sendPasteKey()
def outputTags(beginTag, endTag): setClipboardData(beginTag + endTag) sendPasteKey() sendLefts(len(endTag.decode('utf-8')))
def upperText(text): setClipboardData(text.upper()) sendPasteKey()
def lowerText(text): setClipboardData(text.lower()) sendPasteKey()