[Python] Mouse movment isnt working in game (fortnite) using pydirectinput

Discussão em 'Python' iniciado por Stack, Janeiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I want my mouse to move to nametag of player, when pressing windows its working with the windows crosshair but in game it moves to a random place.

    import pyautogui
    import pydirectinput
    import time
    import keyboard

    def loop1():
    while True:
    image_files = ["Screenshot 2025-01-25 153403.png"]

    for filename in image_files:
    try:
    center_x, center_y = pyautogui.size()
    center_x = center_x // 2
    center_y = center_y // 2
    region = (center_x - 750, center_y - 600, 1500, 1200)
    nametag = pyautogui.locateCenterOnScreen(filename, confidence=0.6, region=region)

    if nametag:
    print("found")
    x, y = nametag
    pydirectinput.moveRel(x, y, duration=0.1)
    print("found file", filename, "in", nametag)
    time.sleep(1)
    continue

    except pyautogui.ImageNotFoundException:
    time.sleep(2)
    print('not found')
    continue
    time.sleep(1)

    while True:
    if keyboard.is_pressed('`'):
    loop1()


    i tried using relative still the same problom-its moving to a "random place" after nametag being found.

    Continue reading...

Compartilhe esta Página