Skip to content

pyautogui failing on vd  #96

@marcelib4s

Description

@marcelib4s

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions