def execute(]str): if str == 'left_mouse click': pyautogui.click( button = 'left' ) print('kam hoise') elif str == 'right_mouse click': pyautogui.click( button = 'right' ) elif str == 'middle_mouse click': pyautogui.click( button = 'middle' ) elif str == 'scroll_up': pyautogui.scroll(10) elif str == 'scroll_down': pyautogui.scroll(-10) elif str == 'scroll_right': pyautogui.hscroll(10) elif str == 'scroll_left': pyautogui.hscroll(-10) elif str == 'page_up': pyautogui.press('pgup') elif str == 'page_down': pyautogui.press('pgdn') elif str == 'zoom_out': pyautogui.keydown('shift') pyautogui.press('+') pyautogui.keyup('shift') elif str == 'zoom_in': pyautogui.keydown('shift') pyautogui.press('-') pyautogui.keyup('shift') elif str == 'refresh': pyautogui.press('f5') elif str == 'screenshot': pyautogui.screenshot() elif str == 'volume_up': pyautogui.press('volumeup') elif str == 'volume_down': pyautogui.press('volumedown') elif str == 'next_track': pyautogui.press('nexttrack') elif str == 'prev_track': pyautogui.press('prevtrack') elif str == 'play/pause': pyautogui.press('playpause')
def move (): deadzone_x = 200 deadzone_y = 200 key_delay = 0.4 PORT = "/dev/ttyACM1" #~ PORT = "/dev/serial/by-id/usb-MBED_MBED_CMSIS-DAP_9900023431864e45001210060000003700000000cc4d28bd-if01" BAUD = 115200 s = serial.Serial(PORT) s.baudrate = BAUD s.parity = serial.PARITY_NONE s.databits = serial.EIGHTBITS s.stopbits = serial.STOPBITS_ONE while True: data = s.readline().decode('UTF-8') data_list = data.rstrip().split(' ') try: x, y, z, a, b = data_list if int(x) < (0 - deadzone_x) : print("A generated") pyautogui.typewrite('aaaaa') # This works, but barely pyautogui.keydown('a') time.sleep(key_delay) pyautogui.keyup('a') if int(x) > deadzone_x: print("D generated") pyautogui.keydown('d') time.sleep(key_delay) pyautogui.keyup('d') if int(y) < (0 - deadzone_y): print("W generated") pyautogui.keydown('w') time.sleep(key_delay) pyautogui.keyup('w') if int(y) > deadzone_y: print("S generated") pyautogui.keydown('s') time.sleep(key_delay) pyautogui.keyup('s') #~ else: #~ pyautogui.keyup('a') #~ pyautogui.keyup('d') #~ pyautogui.keyup('w') #~ pyautogui.keyup('s') #~ print(x, y, z, a, b) except: pass s.close()
def execute(self, str): if str == 'left_mouse click': pyautogui.click(button='left') elif str == 'right_mouse click': pyautogui.click(button='right') elif str == 'up': pyautogui.press('up') elif str == 'down': pyautogui.press('down') elif str == 'right': pyautogui.hscroll(10) elif str == 'scroll_left': pyautogui.hscroll(-10) elif str == 'page_up': pyautogui.press('pgup') elif str == 'page_down': pyautogui.press('pgdn') elif str == 'spacebar': pyautogui.press('space') # elif str == 'middle_mouse click': # pyautogui.click( button = 'middle' ) elif str == 'scroll_up': pyautogui.scroll(10) elif str == 'scroll_down': pyautogui.scroll(-10) elif str == 'scroll_right': pyautogui.hscroll(10) elif str == 'scroll_left': pyautogui.hscroll(-10) elif str == 'up': pyautogui.press('up') elif str == 'down': pyautogui.press('down') elif str == 'page_up': pyautogui.press('pgup') elif str == 'page_down': pyautogui.press('pgdn') elif str == 'zoom_out': pyautogui.keydown('shift') pyautogui.press('+') pyautogui.keyup('shift') elif str == 'zoom_in': pyautogui.keydown('shift') pyautogui.press('-') pyautogui.keyup('shift') elif str == 'refresh': pyautogui.press('f5') elif str == 'screenshot': from time import gmtime, strftime showtime = strftime("%Y-%m-%d%H:%M:%S", gmtime()) #print(showtime) pyautogui.screenshot('../../screenshots/' + showtime + '.jpg') playsound('camera-shutter-click-01.wav') elif str == 'volume_up': pyautogui.keyDown('command') pyautogui.press('up') elif str == 'volume_down': pyautogui.press('volumedown') elif str == 'next_track': pyautogui.press('nexttrack') elif str == 'prev_track': pyautogui.press('prevtrack') elif str == 'play/pause': pyautogui.press('playpause')
def gamecontrol(): while True: if "c" in message.lower(): pyautogui.keydown('q') message = "" pyautogui.keyup('q')