def osx_notify(): try: from osax import OSAX except: print 'appscript not installed ...' sa = OSAX() sa.activate() sa.display_dialog('%s: computations are finished!' % (sys.argv[0]))
def shortenSafari(): Safari = app(u'/Applications/Safari.app') url = Safari.windows[1].current_tab.URL.get() print url short_url = shorten(url) sa = OSAX() sa.set_the_clipboard_to(short_url) print short_url
def insert_text_cb(text): sa = OSAX() # save old clipboard (only text part) oldtext = sa.the_clipboard() # put our text on clipboard sa.set_the_clipboard_to(text) # paste clipboard ME = app(u'System Events').application_processes[u'MarsEdit'] ME.menu_bars[1].menu_bar_items[4].menus[1].menu_items[6].click() # restore old clipboard # need to pause so we don't replace clipboard before it is pasted time.sleep(.5) sa.set_the_clipboard_to(oldtext)
index += 1 try: num = int(raw_input('Enter the number:')) if num > 0 and num <= len(availables): selected = availables[num - 1] except Exception as e: print "invalid input!" exit(1) try: ser = serial.Serial(selected, baud, timeout=timeout) except Exception as e: print "failed to connect the serial port", e sa = OSAX() old_brightness = 0 old_volume = 0 def change_brightness(new_val): global old_brightness, sa if abs(int(new_val) - int(old_brightness)) > 1: cmd = "01SBRI%3.0f" % float(new_val) ser.write(cmd) old_brightness = new_val def change_volume(new_val): global old_volume, sa if abs(int(new_val) - int(old_volume)) > 1: