Есть ли способ внедрить действия мыши в браузер, не полагаясь на решения cdp, js или общесистемные решения? ⇐ Python

Программы на Python
Anonymous
Есть ли способ внедрить действия мыши в браузер, не полагаясь на решения cdp, js или общесистемные решения?

Сообщение Anonymous »

Привет, есть ли способ сделать перетаскивание действий мыши для браузера, не полагаясь на решения cdp, js или sys, кроме того, мое решение не работает, потому что экземпляр браузера не запускается внутри vd

Код: Выделить всё


##################
browser launched in corect display for
#from pyvirtualdisplay import Display
#display = Display(visible=0, size=(1024, 768))
#display.start()

byt as far i know no way to control mouse actions

################

class DisplayWindow:
def __init__(self, width, height, title):
self.display = Xlib.display.Display()
self.screen = self.display.screen()

# Create window attributes manually
self.attributes = {
"background_pixel": self.screen.white_pixel,
"event_mask": Xlib.X.ExposureMask | Xlib.X.ButtonPressMask,
"border_width": 10,
"depth": self.screen.root_depth,
"class": Xlib.X.InputOutput,
"visual": Xlib.X.CopyFromParent
}

self.window = self.create_window(width, height)
self.set_window_title(title)

def create_window(self, width, height):
return self.screen.root.create_window(
0, 0,  # x, y coordinates
width, height,  # width, height
**self.attributes  # Use dictionary unpacking for attributes
)

def set_window_title(self, title):
self.window.set_wm_name(title)

def launch_display(self):
self.window.map()
self.display.sync()
print(f"Display ID ---->{ self.display.get_display_name()}")

async def drag_and_drop(self, x1, y1, x2, y2):

self.window.warp_pointer(x1, y1)
self.display.sync()

# Simulate left mouse button press
fake_input(self.display, Xlib.X.ButtonPress, 1)
self.display.sync()

# Move the mouse pointer to the ending coordinates
self.window.warp_pointer(x2, y2)
self.display.sync()

# Simulate left mouse button release
fake_input(self.display, Xlib.X.ButtonRelease, 1)
self.display.sync()

###### some coide heare ##########

#display_window.launch_display()
#os.environ['DISPLAY'] = ':0'

#def is_display_available(display_id):
#    try:
#        display = Xlib.display.Display(display_id)
#        return True
#    except Xlib.error.DisplayConnectionError:
#        return False

#if not is_display_available(':0'):
#    print("Virtual display is not available")
#    exit(1)

launching asynic browser chrome and making actions

я попробовал js-инъекцию, не удалось, причина той же политики происхождения, попытка pyautogui не удалась, не подходит для задачи, попробовал методы селена, ошибка, причина обнаружения cdp и многое другое

Подробнее здесь: https://stackoverflow.com/questions/790 ... -on-cdp-or

Вернуться в «Python»