def open_eclipse(): """Open eclipse typing string 'eclipse' in menu search.""" open_main_menu() key.type_string("eclipse", 0) key.tap(long(key.K_RETURN)) wait_target(ECLIPSE_OPEN_PERSPECTIVE_IMG)#is better than 'time.sleep' to wait eclipse to be ready. time.sleep(1)
def letra(self): a = 0 while a == 0: #levantamos la posision del puntero en el visor1 y la usamos en el emisor con = psycopg2.connect(DSN) cur = con.cursor() query = "select letra, puedeescribir from sesion where id = 1;" cur.execute(query) con.commit() for linea in cur.fetchall(): # estas lineas hay que cambiarlas por las que van # recuperar los valores de las coordenadas if linea[1] == 1: letra = linea[0].replace('-','') if letra <> '-': key.type_string(letra,0) #Actualiza letra a nada con = psycopg2.connect(DSN) cur = con.cursor() query_letra = "update sesion set letra = '-' where id = 1;" cur.execute(query_letra) query_puedeescribir = "update sesion set puedeescribir = 0 where id = 1;" cur.execute(query_puedeescribir) con.commit() cur.close() cur.close()
def add_sample_well_description(self, sample_number=0, image_file="sample_well_description.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates( os.path.join(self.image_directory, image_file)) #path to the image except IOError: logging.warning( 'Image file Sample Well Description not found. Quitting..') return if self._windowMgr._pos == None: logging.warning( 'Could not add sample well description. Button not found on screen' ) if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 80, self._windowMgr._pos[1] + 8 ) #add position offset mouse.move(position[0], position[1]) mouse.click() time.sleep(0.5) if sample_number: sampleString = str('sample%i' % sample_number) else: sampleString = '' sample_time = datetime.datetime.now() sample_time = ''.join([ sampleString, 'time', str(sample_time.hour), 'h', str(sample_time.minute), 'm' ]) key.type_string(sample_time)
def openURL(): """opens website automatically if the resolution of the screen is usual ( HD or FHD ), else asks the user to open it manually""" width, heigth = screen.get_size() if heigth == 1080: mouse.smooth_move(200, 60) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) elif heigth == 768: mouse.smooth_move(200, 60) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) else: print 'Please open http://www.nytimes.com/interactive/science/rock-paper-scissors.html then type OK' if 'ok'.lower() == raw_input(): print 'TY' time.sleep(1) speed = 0 key.type_string('http',speed) key.tap('.', key.MOD_SHIFT) key.tap('6', key.MOD_SHIFT) key.tap('6', key.MOD_SHIFT) key.type_string('www.nytimes.com',speed) key.tap('6', key.MOD_SHIFT) key.type_string('interactive',speed) key.tap('6', key.MOD_SHIFT) key.type_string('science',speed) key.tap('6', key.MOD_SHIFT) key.type_string('rock-paper-scissors.html',speed) key.tap('6', key.MOD_SHIFT) key.tap(key.K_RETURN)
def ecl_jboss_clear(): """Clicks on tab 'Servers' in the eclipse, and clean all published resources on JBOSS container.""" ecl_servers() wait_target_click(ECLIPSE_JBOSS_LOGO_IMG, RIGHT_BUTTON) time.sleep(1) key.type_string("c", 0) time.sleep(1) key.tap(long(key.K_RETURN))
def simkey_type_words(pos, words, interal=0.1): mouse.move(*pos) mouse.click() for word in words: time.sleep(interal) key.tap('a', key.MOD_CONTROL) time.sleep(interal) key.type_string(word) key.tap(key.K_RETURN)
def ecl_show_view(search): """Uses a series of shortcuts to search functionality in eclipse and selects then.""" key.tap(long(ord('w')),long(key.MOD_ALT)) key.tap(long(ord('v'))) key.tap(long(ord('o'))) time.sleep(1) key.tap(long(key.K_DELETE)) key.type_string(search, 0) time.sleep(1) move_middle_bottom() mouse.click(LEFT_BUTTON) #to gain focus key.tap(long(key.K_RETURN)) time.sleep(1)
def maintainUP(): key.tap(key.K_ALT) key.tap(key.K_RIGHT) for x in range(6): key.tap(key.K_DOWN) key.tap(key.K_RETURN) time.sleep(1) for x in range(8): key.tap('\t') key.type_string("130") time.sleep(1) key.tap('\t',key.MOD_SHIFT) time.sleep(1) key.tap(key.K_RETURN)
def login(): # key.tap(key.Code.SPACE, [key.Modifier.META]) # print('star sleep') # time.sleep(1) # print('end sleep') # key.tap('t', delay=1) # time.sleep(2) # key.tap(key.Code.RETURN) # time.sleep(5) key.type_string('3y7z6qmc') key.tap(key.Code.RETURN) time.sleep(5) key.tap(key.Code.RETURN)
def add_sample_well_description(self, sample_number=0, image_file="sample_well_description.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates(os.path.join(self.image_directory, image_file)) # path to the image except IOError: logging.warning("Image file Sample Well Description not found. Quitting..") return if self._windowMgr._pos == None: logging.warning("Could not add sample well description. Button not found on screen") if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 80, self._windowMgr._pos[1] + 8) # add position offset mouse.move(position[0], position[1]) mouse.click() time.sleep(0.5) if sample_number: sampleString = str("sample%i" % sample_number) else: sampleString = "" sample_time = datetime.datetime.now() sample_time = "".join([sampleString, "time", str(sample_time.hour), "h", str(sample_time.minute), "m"]) key.type_string(sample_time)
def login(self): for k, v in self.config.items(): if k == 'qq_path': continue self.open_qq() time.sleep(7) self.double_click_qq_input_text_box() time.sleep(1) key.tap(key.K_SHIFT) key.type_string(k) key.type_string('\t') self.double_click_passwd_input_text_box() key.tap(key.K_SHIFT) time.sleep(1) key.type_string(v) key.tap(key.K_RETURN) time.sleep(7)
def on_type(self, string, wpm=0, msg=None): K.type_string(string, wpm)
pick_unit(unit) # place unit go_and_click(570, 357) # menu go_and_click(995, 30) # test go_and_click(512, 475) time.sleep(2) key.tap(key.K_RETURN) time.sleep(.05) key.type_string('reveal map') time.sleep(.05) key.tap(key.K_RETURN) time.sleep(.05) key.tap(key.K_RETURN) time.sleep(.05) key.type_string('no fog') time.sleep(.05) key.tap(key.K_RETURN) time.sleep(1) stdin, stdout = start_recording(unit, deselect) # select unit go_and_click(480, 275)
def key_stroke(res): key.type_string(res)
def dataReceived(self, data): #print "datareceived", data while data: try: decode, index = json_decode(data) except ValueError: # something went wrong.. FIXME return data = data[index:] if not isinstance(decode, dict): # something went wrong, gtfo for now, FIXME return command = decode.get('command') if command == 'mouse': pos = mouse.get_pos() action = decode.get('action') if action == 'click': for i in range(decode.get('n') or 1): mouse.click(BUTTONS[decode.get('b') - 1]) elif action == 'move': try: mouse.move(pos[0] + decode.get('dx'), pos[1] + decode.get('dy')) except ValueError: pass elif action == 'press': mouse.toggle(True, BUTTONS[decode.get('b') - 1]) elif action == 'release': mouse.toggle(False, BUTTONS[decode.get('b') - 1]) elif command == 'type': key.type_string(decode['string']) elif command == 'press_key': key.toggle(getattr(key, 'K_' + decode['key'].upper()), True) elif command == 'release_key': key.toggle(getattr(key, 'K_' + decode['key'].upper()), False) elif command == 'kill': self.kill_app(decode['uid']) elif command == 'capture': pos = mouse.get_pos() size = decode.get('size') maxx, maxy = screen.get_size() rect = (( max(0, min((pos[0] - size[0] / 2), maxx - size[0])), max(0, min((pos[1] - size[1] / 2), maxy - size[1])) ), (size[0], size[1])) try: bitmap.capture_screen(rect).save('tmp.png') except ValueError: return self.send(mouse_pos=(pos[0] - rect[0][0], pos[1] - rect[0][1])) #print "sending capture" self.send_image('tmp.png') elif decode.get('run') in zip(*self.commands)[0]: self.execute(decode.get('run'), decode.get('arguments'))
def openFile(): key.tap('o', key.MOD_CONTROL) time.sleep(1) key.type_string("test.stl") key.type_string(string) key.tap(key.K_RETURN)
from autopy import key from time import sleep sleep(3) key.type_string(' ', 0)