Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyautogui failing on vd #96

Open
marcelib4s opened this issue Oct 2, 2024 · 0 comments
Open

pyautogui failing on vd #96

marcelib4s opened this issue Oct 2, 2024 · 0 comments

Comments

@marcelib4s
Copy link

marcelib4s commented Oct 2, 2024

HI i saw some questions for similar err im trying to use py virtual display with pyautogui but no mouse actions preformed sorry if this the wrong place to ask such question

Size(width=945, height=1028) --> size is printed correctly print(pyautogui.size()) but dragh and drop actions fail

my implementation --> class VirtualDisplay:

def __init__(self, state) -> None:


    if state not in [1,0]:

        raise Exception("an errr inwalid input int not in ->>(0, 1)")

    self.state = state


    self.display = Display(visible=state, size=(945, 1028)) # backend="xvfb", use_xauth=True



    

def virtual_display(self ):



    self.display.start()
    print("Display 1 PID:", self.display.pid)
def v_d_q(self):


    self.display.stop()

async def get_mouse_position(self):
    xdisplay = Xlib.display.Display()
    root = xdisplay.screen().root
    mouse_position = root.query_pointer()
    print(mouse_position.root_x, mouse_position.root_y)

async def drag_and_drop(self, poz__x: tuple):

    import pyautogui

   
        
    #pyautogui._pyautogui_x11._display = Xlib.display.Display(
    #    f":{self.display.pid}" or os.envrion['DISPLAY']
    #    )
    print(pyautogui.size())
  
   
    print(pyautogui._pyautogui_x11._display)
    poz = poz__x[0]+50

    import time


    # Move the mouse to the start position within the virtual display
    print("stasdaw")
    start_x, start_y = 507, 551
    end_x, end_y = poz+15, 551

    pyautogui.moveTo(start_x, start_y)
    time.sleep(0.1)  # 
    pyautogui.mouseDown()
    time.sleep(0.1)  # 
    
    pyautogui.moveTo(end_x, end_y)
    time.sleep(0.1)  # 
    pyautogui.mouseUp()
    print("stasdawdsdefgse")




    await self.get_mouse_position()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant