def download_all(self): dlc_list = App.get_running_app().get_main_screen( ).character_list_for_dlc for text in dlc_list: arguments = text.split('#', 2) char = arguments[0] shared_link = arguments[1] try: if shared_link.find( "drive.google.com" ) == -1: # checks for google drive shared_link try: direct_link = shared_link except Exception as e: print("Error: " + e) else: try: file_id = shared_link.split('id=') try: direct_link = 'https://drive.google.com/uc?export=download&id=' + file_id[ 1] except IndexError: dlc_list = App.get_running_app().get_main_screen( ).character_list_for_dlc char_link = char + '#' + shared_link dlc_list.remove(char) self.dismiss() temp_pop = MOPopup("Error downloading", "Can't download " + char, "OK") temp_pop.open() return except Exception as e: print("Error: " + e) path = 'characters/' + char + '.zip' r = requests.get(direct_link, allow_redirects=True) open(path, 'wb').write(r.content) with ZipFile(path) as zipArch: zipArch.extractall("characters") os.remove(path) self.clean(arguments[0]) char = arguments[0] + '#' + arguments[1] + '#' + arguments[2] self.overwrite_ini(arguments[0], arguments[1], arguments[2]) except KeyError: dlc_list = App.get_running_app().get_main_screen( ).character_list_for_dlc char_link = char + '#' + shared_link dlc_list.remove(char_link) temp_pop = MOPopup("Error downloading", "Can't download " + char, "OK") temp_pop.open() App.get_running_app().get_main_screen().character_list_for_dlc = [] KeyboardListener.refresh_characters() self.dismiss(animation=False)
def download_character(self, char_name, link, ver): try: if link.find( "drive.google.com") == -1: #checks for google drive link try: direct_link = link except Exception as e: print("Error: " + e) else: try: file_id = link.split('id=') try: direct_link = 'https://drive.google.com/uc?export=download&id=' + file_id[ 1] except IndexError: dlc_list = App.get_running_app().get_main_screen( ).character_list_for_dlc char = char_name + '#' + link dlc_list.remove(char) self.dismiss() temp_pop = MOPopup("Error downloading", "Can't download " + char_name, "OK") temp_pop.open() return except Exception as e: print("Error: " + e) path = 'characters/' + char_name + '.zip' r = requests.get(direct_link, allow_redirects=True) open(path, 'wb').write(r.content) with ZipFile(path) as zipArch: zipArch.extractall("characters") os.remove(path) dlc_list = App.get_running_app().get_main_screen( ).character_list_for_dlc char = char_name + '#' + link + '#' + ver dlc_list.remove(char) self.overwrite_ini(char_name, link, ver) KeyboardListener.refresh_characters() self.dismiss(animation=False) self.clean(char_name) except KeyError: self.dismiss() temp_pop = MOPopup("Error downloading", "Can't download " + char_name, "OK") temp_pop.open() except Exception as e: print("Error 2: " + e)
from mouse_listener import MouseListener from keyboard_listener import KeyboardListener from screen_recorder import ScreenRecorder from data_handler import DataHandler import keyboard import time mouse_listener = MouseListener() keyboard_listener = KeyboardListener() screen_recorder = ScreenRecorder() data_handler = DataHandler() keyboard.wait('f12') screen_recorder.start_recording() keyboard_listener.start_listening() mouse_listener.start_listening() while True: time.sleep(1) screenshot = screen_recorder.get_screenshot() keyboard_state = keyboard_listener.get_state() mouse_state = mouse_listener.get_state() data_handler.submit(screenshot, keyboard_state, mouse_state) if keyboard.is_pressed('f12'): break print(len(keyboard_listener.get_state()))
copy_text() data = get_clipboard_data() data = modifications[modification](data) print(data) copy_to_clipboard(data) paste_text() print(f'{modification} done') combinations = { 'combo1': Combo(['alt'], '1', modify, 'upper'), 'combo2': Combo(['alt'], '2', modify, 'lower'), 'combo3': Combo(['alt'], '3', modify, 'cap_first'), 'combo4': Combo(['alt'], '4', modify, 'cap_all'), 'combo5': Combo(['alt'], '5', modify, 'snake_case'), 'combo6': Combo(['alt'], '6', modify, 'reverse') } keywords = { 'help': KeyWord('--help', replace, '--help', 'Instead of this message, the function could instead alert emergency services 🚨🚨🚨'), 'signature': KeyWord('--sig', replace, '--sig', 'Kind Regards\nJohn Smith from Generic Company'), '100': KeyWord('--100', replace, '--100', str([x for x in range(100)])) } keyboard_listener = KeyboardListener(combinations=combinations, keywords=keywords) keyboard_listener.run()
spell = Spells[line[2]] diff = int(line[3]) cd = Cooldowns[spell] - diff summoner_timers.add_timer(lane, spell, cd) elif line[0] == 'SUM': if line[1] not in valid_roles or line[ 2] not in valid_spells or line[3] not in valid_spells: return lane = Lanes[line[1]] spell1 = Spells[line[2]] spell2 = Spells[line[3]] spells_per_lane[lane] = (spell1, spell2) except Exception as e: print(e) if __name__ == '__main__': global listener file_handler = FileModifiedHandler(DIRECTORY_PATH, FILE_NAME, callback) listener = KeyboardListener(execute, summoner_timers, spells_per_lane) try: while True: time.sleep(1) except KeyboardInterrupt: file_handler.stop() listener.stop()
def build(self): msm = MainScreenManager() self.keyboard_listener = KeyboardListener() location_manager.load_locations() return msm
def start(self): while True: event, values = self.__window.read(timeout=10) if event == sg.WIN_CLOSED or event == '-EXIT-': if Global.is_server_running: requests.get(f'http://{Global.ip}:{Global.port}/shutdown') break elif event == '-SHARE-': Global.role = 'share' elif event == '-CONTROL-': Global.role = 'control' elif event == '-START-': self.__window.hide() if Global.role == 'share': threading.Thread(target=make_screenshots, args=('screenshot.jpg', Global.quality, Global.region)).start() while not keyboard.is_pressed('Esc'): keyboard.play(Global.keyboard_events) Global.keyboard_events.clear() for event in Global.mouse_events: if event['event_name'] == 'click' and event[ 'pressed'] == True and event[ 'button'] == 'left': Mouse.press_left() elif event['event_name'] == 'click' and event[ 'pressed'] == True and event[ 'button'] == 'right': Mouse.press_right() elif event['event_name'] == 'click' and event[ 'pressed'] == False and event[ 'button'] == 'left': Mouse.release_left() elif event['event_name'] == 'click' and event[ 'pressed'] == False and event[ 'button'] == 'right': Mouse.release_right() elif event['event_name'] == 'scroll': Mouse.scroll(10 * event['dx'], 10 * event['dy']) elif event['event_name'] == 'move': Mouse.move_to(event['x'], event['y']) Global.mouse_events.clear() elif Global.role == 'control': KeyboardListener().start_listen() MouseListener().start_listen() cv2.namedWindow('Window') screensize = pyautogui.size() x, y, w, h = cv2.getWindowImageRect('Window') cv2.moveWindow('Window', screensize.width // 2 - w // 2, screensize.height // 2 - h // 2) ImageFile.LOAD_TRUNCATED_IMAGES = True while cv2.getWindowProperty('Window', 1) > 0: keyboard_events, mouse_events = Global.keyboard_events, Global.mouse_events Global.keyboard_events = [] Global.mouse_events = [] res = requests.get( f'http://{Global.ip}:{Global.port}/data', data={ 'mouse_events': json.dumps(mouse_events), 'keyboard_events': json.dumps(keyboard_events) }) if res.content: stream = io.BytesIO(res.content) frame = Image.open(stream).convert("RGBA") stream.close() frame = numpy.array(frame) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) cv2.imshow('Window', frame) if not cv2.waitKey(1): break self.__window.un_hide() elif event == '-APPLY-': Global.ip = values['ip'] Global.port = int(values['port']) Global.region = (values['-X-'], values['-Y-'], values['-WIDTH-'], values['-HEIGHT-']) Global.quality = values['-QUALITY-'] try: if Global.role == 'share': run_server(Global.ip, Global.port) except Exception as e: ctypes.windll.user32.MessageBoxA(None, bytes(str(e), 'utf-8'), b"Error", 0x30 | 0x0) self.__window['-TEST-CONNECT-'].update(disabled=False) self.__window['-APPLY-'].update(disabled=True) self.__window['-SHARE-'].update(disabled=True) self.__window['-CONTROL-'].update(disabled=True) self.__window['-X-'].update(disabled=True) self.__window['-Y-'].update(disabled=True) self.__window['-WIDTH-'].update(disabled=True) self.__window['-HEIGHT-'].update(disabled=True) self.__window['-START-'].update(disabled=False) elif event == '-TEST-CONNECT-': start = time.time() try: requests.get(f'http://{Global.ip}:{Global.port}/ping') except Exception as e: ctypes.windll.user32.MessageBoxA(None, bytes(str(e), 'utf-8'), b"Error", 0x30 | 0x0) ping_ms = round((time.time() - start) * 1000, 1) ctypes.windll.user32.MessageBoxA( None, bytes(f"Ping: {ping_ms} ms", 'utf-8'), b"Info", 0x40 | 0x0) self.__window.close()
def download_character(self, char_name, link, ver): try: if link.find("drive.google.com") == -1: #checks for google drive link try: direct_link = link except Exception as e: print("Error: " + e) else: try: file_id = link.split('id=') try: id = file_id[1] URL = "https://docs.google.com/uc?export=download" session = requests.Session() response = session.get(URL, params={'id': id}, stream=True) token = self.get_confirm_token(response) if token: params = {'id': id, 'confirm': token} response = session.get(URL, params=params, stream=True) direct_link = response.url except IndexError: dlc_list = App.get_running_app().get_main_screen().character_list_for_dlc char = char_name + '#' + link dlc_list.remove(char) self.dismiss() temp_pop = MOPopup("Error downloading", "Can't download " + char_name, "OK") temp_pop.open() return except Exception as e: print("Error: " + e) try: shutil.rmtree('characters/'+char_name) except Exception as e: print(e) path = 'characters/' + char_name + '.zip' r = requests.get(direct_link, allow_redirects=True) open(path, 'wb').write(r.content) with ZipFile(path) as zipArch: zipArch.extractall("characters") os.remove(path) dlc_list = App.get_running_app().get_main_screen().character_list_for_dlc char = char_name + '#' + link + '#' + ver dlc_list.remove(char) self.overwrite_ini(char_name, link, ver) KeyboardListener.refresh_characters() self.dismiss(animation=False) self.clean(char_name) except (KeyError, zipfile.BadZipFile, Exception) as e: print(e) self.dismiss() temp_pop = MOPopup("Error downloading", "Can't download " + char_name, "OK") temp_pop.open() return except Exception as e: print("Error 2: " + e) temp_pop = MOPopup("Download complete", "Downloaded " + char_name, "OK") temp_pop.open()
def download_all(self): dlc_list = App.get_running_app().get_main_screen().character_list_for_dlc for text in dlc_list: arguments = text.split('#', 2) char = arguments[0] shared_link = arguments[1] try: if shared_link.find("drive.google.com") == -1: # checks for google drive shared_link try: direct_link = shared_link except Exception as e: print("Error: " + e) else: try: file_id = shared_link.split('id=') try: id = file_id[1] URL = "https://docs.google.com/uc?export=download" session = requests.Session() response = session.get(URL, params={'id': id}, stream=True) token = self.get_confirm_token(response) if token: params = {'id': id, 'confirm': token} response = session.get(URL, params=params, stream=True) direct_link = response.url except IndexError: dlc_list = App.get_running_app().get_main_screen().character_list_for_dlc char_link = char + '#' + shared_link dlc_list.remove(char) self.dismiss() temp_pop = MOPopup("Error downloading", "Can't download " + char, "OK") temp_pop.open() return except Exception as e: print("Error: " + e) try: shutil.rmtree('characters/' + char) except Exception as e: print(e) path = 'characters/' + char + '.zip' r = requests.get(direct_link, allow_redirects=True) open(path, 'wb').write(r.content) with ZipFile(path) as zipArch: zipArch.extractall("characters") os.remove(path) self.clean(arguments[0]) char = arguments[0] + '#' + arguments[1] + '#' + arguments[2] self.overwrite_ini(arguments[0], arguments[1], arguments[2]) except (KeyError, zipfile.BadZipFile, Exception) as e: print(e) try: dlc_list = App.get_running_app().get_main_screen().character_list_for_dlc char_link = char + '#' + shared_link dlc_list.remove(char_link) except ValueError: pass temp_pop = MOPopup("Error downloading", "Can't download " + char, "OK") temp_pop.open() except PermissionError: os.remove(path) shutil.rmtree('characters/' + char) temp_pop = MOPopup("Error downloading", "Can't download " + char + ". Permission Error, character folder deleted, try again.", "OK") temp_pop.open() App.get_running_app().get_main_screen().character_list_for_dlc = [] KeyboardListener.refresh_characters() temp_pop = MOPopup("Download complete", "You downloaded everything.", "OK") temp_pop.open() self.dismiss(animation=False)
def start_keyboard_listener(): keyboard_listener = KeyboardListener(keywords=keywords) keyboard_listener_thread = start_thread(target=keyboard_listener.run) return keyboard_listener
from Queue import Queue from keyboard_listener import KeyboardListener from dispatcher import Dispatcher print "Welcome to Jeremy's Test Jukebox 3.0" print '' q = Queue() KeyboardListener(q).start() Dispatcher(q, "/Users/jeremy/src/jukebox").start()
def build_scene(): """ builds the simulation, is run by agx internaly. Returns: """ print("build staring") """ Ads Water and seafloor to the simulation""" water_geometry, seafloor = MakeWater.make_water(WATER_DENSITY, WATER_LENGTH, WATER_WIDTH, WATER_DEPTH) controller = agxModel.WindAndWaterController() controller.addWater(water_geometry) print("buildt water controller") """Creates a pid controller for depth and trim""" rov_pid = build_pid_controller(p=ROV_K_P, i=ROV_K_I, d=ROV_K_D, mode=(1, 0, 0), setpoint=ROV_DEPTH_SETPOINT, direction=1, max_out=MAX_WING_ANGLE, min_out=MIN_WING_ANGLE, name="rov_pid") pid_trim = build_pid_controller(p=K_P_TRIM, i=K_I_TRIM, d=K_D_TRIM, direction=0, mode=(1, 0, 0), max_out=TRIM_MAX_OUT, min_out=TRIM_MIN_OUT, name="pidTrim", setpoint=0) keyboard = KeyboardListener(rov_pid, plot) print("buildt pid's for rov") """Creates the rov""" rov = RovAssembly(keyboard) rov.setPosition(agx.Vec3(-WATER_LENGTH + 10, 0, 0)) rov.setName("rov") rov.setRotation(agx.EulerAngles(0, 0, math.pi)) setBodyViscousDrag(rov, controller) print("buildt rov") """builds a lock for the system to stablilize it the lock is soft so that the rov can move but it takes more to move it""" lock = build_angular_lockJoint(rov.getRigidBody('rovBody'), 1e-2, 1e-12, 1e-2, 1e-12) print("buildt lock for rov") """ creates arduino simulations""" arduino_sensor = ArduinoSensor(rov, seafloor.getShape().asHeightField()) arduino_stepper = ArduinoStepper(rov_pid, pid_trim, rov) print("buildt pid for boat") pid_boat = build_pid_controller(p=BOAT_K_P, i=BOAT_K_I, d=BOAT_K_D, direction=0, name="pidBoat", max_out=2, min_out=-2, setpoint=BOAT_SPEED, mode=(1, 0, 0)) """Creates the boat to tow the rov""" ship = Ship(controller) ship.setName('ship') ship.setRotation(agx.EulerAngles(0, 0, math.pi)) ship.setPosition(agx.Vec3(-WATER_LENGTH + 20 + WIRE_LENGTH, 0, 0)) ship_echo = Boat_Sensor(ship, seafloor.getShape().asHeightField()) ship.setVelocity(agx.Vec3(-1, 0, 0)) ship_controller = Boat_Controller(ship, pid_boat, arduino_stepper) print("buildt ship") """builds the wire and wire controller""" wire, wire_renderer = MakeWire().create_wire(1030, 0.001, ship, agx.Vec3(2, 0, 0), rov, agx.Vec3(*WIRE_POS_ROV)) setWireViscousDrag(wire, controller) print("build Wire") """Adds rov, boat, controller, and pid to the simulation""" add_objects_to_sim(arduino_sensor, arduino_stepper, wire, wire_renderer) print("added sensor, stepper, wire and wire rederer") add_objects_to_sim(ship, ship_controller, seafloor, water_geometry, controller) print( "added ship and ship controller, seafloor, water geometry and controller" ) add_objects_to_sim(rov, rov_pid, lock) print("added rov and rov_pid and lock") sim().addEventListener(ship_echo) print("added ship sensor") sim().addEventListener(keyboard) print("added keyboard listener") sim().setTimeStep(SIM_TIME_STEP) set_camera_to_rov(rov) print_builancy(rov.link1) """locks the rov in fixed position, for mounting wing and cable to rov""" if adjust_rov: lock1 = agx.LockJoint(rov.link1) sim().add(lock1)