def toggleAutorun(): global autorun autorun = not autorun if autorun: #buttonAutorun.select() buttonAutorun.configure(background=green, activebackground=green) if GetWindowText(GetForegroundWindow()) == "Phasmophobia": try: pydirectinput.keyDown('shiftleft') pydirectinput.keyDown('shiftright') except: editLabel("Uh Oh. Something went wrong.") endProgram() else: disableAutorun() editLabel("Please start/focus Phasmophobia.") else: #buttonAutorun.deselect() buttonAutorun.configure(bg=red, activebackground=red) try: pydirectinput.keyUp('shiftleft') pydirectinput.keyUp('shiftright') except: editLabel("Uh Oh. Something went wrong.") endProgram()
async def on_message(message): if str(message.channel) == 'pc-control': message.content = message.content.lower() if message.content in KEYS: control.keyDown(message.content) sleep(0.4) control.keyUp(message.content) else: if message.content == 'mup': control.move(0, -200) if message.content == 'mdown': control.move(0, 200) if message.content == 'mleft': control.move(-200, 0) if message.content == 'mright': control.move(200, 0) if message.content == 'm1': control.click(button='left') if message.content == 'm2': control.click(button='right') if message.content.startswith('say'): keyboard.type(message.content[4:]) await message.delete()
def enterline(self, cmd): cb.copy(cmd) kb.press("enter", _pause=False) kb.keyDown("ctrl", _pause=False) kb.press("v", _pause=False) kb.keyUp("ctrl", _pause=False) kb.press("enter", _pause=False)
def reset_game(windowPos): #windowPos[0] = windowPos[0] + 960 #windowPos[1] = windowPos[1] + 540 #sets positions to the middle of the screen print("Clicking the screen") pg.click(windowPos[0] + 10, windowPos[1]) # clicking next to the logo sleep(0.1) pg.moveRel(0, 50, 1) sleep(0.2 + (randint(0,1000)/10000)) print("Pressing escape down") pdi.keyDown('esc') sleep(0.1 + (randint(0,1000)/10000)) print("releasing escape") pdi.keyUp('esc') sleep(1) #Single Player Testing here try: loc = pg.locateCenterOnScreen(images_path + images["restart"]) except Exception as e: raise print("Did not find single player reset button.") try: loc = pg.locateCenterOnScreen(images_path + images["reset"]) except Exception as e: raise print("Did not find Online reset button. Closing...") sys.exit(0) print("Clicking reset") pdi.moveTo(loc[0],loc[1], 0.2) autopy.mouse.click() sleep(0.2) autopy.mouse.click() print('waiting for reset to complete (' + str(rs_wait) + ' seconds)') sleep(rs_wait)
def run(self): while True: pydirectinput.move(1,1) pydirectinput.click(self.x,self.y) time.sleep(0.2) for move in range(642): pydirectinput.move(1,0) #For harvesting pydirectinput.keyDown("f") pydirectinput.keyUp("f") for move in range(316): pydirectinput.move(-2,0) pydirectinput.mouseDown() pass pydirectinput.mouseUp() pydirectinput.keyDown("s") time.sleep(0.1) pydirectinput.keyUp("s") time.sleep(0.5) print("Complete") pass
def PressAndHoldKey(Key, Seconds): try: pydirectinput.keyDown(Key) time.sleep(Seconds) pydirectinput.keyUp(Key) except: print(f"Couldn't hold Key: {Key} for {Seconds} seconds.")
def move_player(self): if self.point.current_status != -1: key = chr(int(self.keyboard_parameters[self.point.current_status])) pydirectinput.keyDown(key) else: for elem in self.keyboard_parameters: pydirectinput.keyUp(chr(int(elem)))
def releaseKey(k): """ Release the given key """ if platform == "linux" or platform == "linux2": pyautogui.keyUp(k) elif platform == "win32": import pydirectinput pydirectinput.keyUp(k)
def update_keys(pressed_buttons, packet, config): """ Updates key presses :param pressed_buttons: The Buttons object containing currently pressed buttons (as of last controller update) :param packet: The packet of data we are handling :param config: The input configuration """ incoming = list(packet) pressed = list(pressed_buttons) i = 0 while i < incoming.__len__(): # we only need to make a change if the data aren't the same if pressed[i] != incoming[i]: # we will drive the mouse separately; skip these if i == 7 or i == 8: pass else: if pressed[i]: # print(config[i], ": RELEASE", sep="") # for debug pydirectinput.keyUp(config[i]) else: # print(config[i], ": PRESS", sep="") # for debug pydirectinput.keyDown(config[i]) # increment the index i += 1
def _type_command(self, string): copy(string) press('/') keyDown('ctrl') keyDown('v') keyUp('v') keyUp('ctrl') press('enter')
def loop(): time.sleep(random.uniform(0, 2)) pydirectinput.keyDown(e.get()) pydirectinput.keyUp(e.get()) if value == False: pass else: root.after(100, loop)
def press(button, seconds=1): pydirectinput.keyDown(button) print("Pressed " + button) time.sleep(seconds) pydirectinput.keyUp(button) print("Released " + button) time.sleep(TIME_BETWEEN_COMMANDS)
def keyboard_write(message): for letter in message: if letter.isupper(): pydirectinput.keyDown('shift') pydirectinput.press(letter.lower()) pydirectinput.keyUp('shift') else: pydirectinput.press(letter)
def type(self, str): if isinstance(str, list): for char in str: auto_input.keyDown(char) auto_input.keyUp(char) else: auto_input.keyDown(str) auto_input.keyUp(str)
def wasd_movement(): pydirectinput.keyDown('w') time.sleep(1) pydirectinput.keyUp('w') time.sleep(1) pydirectinput.keyDown('d') time.sleep(0.25) pydirectinput.keyUp('d') time.sleep(1)
async def func(chatdata): for c in chatdata.items: message = c.message.lower() if message in "up down enter h left right space".split(): print(f"{c.author.name} had pressd {message.upper()}!") pydirectinput.keyDown(message) pydirectinput.keyUp(message) await chatdata.tick_async()
def move_l_one_smol(): pydirectinput.keyDown('shiftleft') time.sleep(0.01) pydirectinput.keyDown('a') time.sleep(0.05) print("go left one block") pydirectinput.keyUp('a') pydirectinput.keyUp('shiftleft') time.sleep(0.05)
def step(self, action, prev_action): print(f"action: {action}") print(f"Mouse Action: {MouseActionSpace[action[1]]}") upgrade = random.randrange(1, 9) pydirectinput.press(str(upgrade)) pydirectinput.keyUp(ActionSpace[prev_action[0]]) pydirectinput.keyDown(ActionSpace[action[0]]) pydirectinput.moveTo(MouseActionSpace[action[1]][0], MouseActionSpace[action[1]][1])
def game_start(): time.sleep(10) logger.plog(f"Level up E spell") pydirectinput.keyDown('ctrl') pydirectinput.press('e') pydirectinput.keyUp('ctrl') time.sleep(5) if last_screen == 'ingame': buy_from_shop(shop_list)
def key_tab(btn): if type(btn) == str: pydirectinput.keyDown(btn) pydirectinput.keyUp(btn) else: for bt in btn: pydirectinput.keyDown(bt) for bt in btn: pydirectinput.keyUp(bt)
def walkingMacro(): pydirectinput.keyDown('w') time.sleep(3) comparing() pydirectinput.keyUp('w') pydirectinput.keyDown('s') comparing() time.sleep(3) pydirectinput.keyUp('s')
def yellowLightIncrease(): """ """ """ """ """ """ pydirectinput.keyDown("w") time.sleep(1) pydirectinput.keyUp("w")
def yellowLight(): """ """ """ """ """ """ pydirectinput.keyDown("s") time.sleep(1) pydirectinput.keyUp("s")
def nearToStationIncrease(): """ """ """ """ """ """ pydirectinput.keyDown("w") time.sleep(1) pydirectinput.keyUp("w")
def Button_Press(button: str, delay: int) -> None: """Control button press and duration Args: button (str): key you wish to press ex: "w" delay (int): time you wish to hold the key down in sec. """ keyDown(button) sleep(delay) keyUp(button)
def timeAndDate(): #clipboard.copy(time.strftime('%d-%m-%Y %H-%M-%S', time.localtime()) + ' ') pydirectinput.keyDown('ctrl', _pause=False) pydirectinput.keyDown('a', _pause=False) pydirectinput.keyUp('a', _pause=False) pydirectinput.keyUp('ctrl', _pause=False) #pydirectinput.typewrite(time.strftime('%d-%m-%Y %H-%M-%S', time.localtime()) + ' ', _pause=False) #slower pyautogui.typewrite(time.strftime('%d-%m-%Y %H-%M-%S', time.localtime()) + ' ', _pause=False) #faster
def back_and_recall(): pydirectinput.keyUp('shift') pydirectinput.press('f') pydirectinput.press('g') pydirectinput.press('s') right_click(1665, 1060) time.sleep(10) pydirectinput.press('b') time.sleep(10) buy_from_shop(shop_list)
def greenLight(): """ """ """ """ """ """ pydirectinput.keyDown("w") time.sleep(2) pydirectinput.keyUp("w")
def take_action(self, action): if action != None: if 'p' in str(action): pydirectinput.press(self.actions_d[str(action)]) return None else: self.random_t_keydown = 0.09 pydirectinput.keyDown(self.actions_d[str(action)]) time.sleep(self.random_t_keydown) pydirectinput.keyUp(self.actions_d[str(action)])
def clicks_and_typing(): pydirectinput.moveTo(500, 300) time.sleep(1) pydirectinput.click(500, 400) pydirectinput.keyDown('g') time.sleep(0.05) pydirectinput.keyUp('g') time.sleep(0.05) pydirectinput.press(['c', 'v', 't']) time.sleep(0.05) pydirectinput.typewrite('myword')