[Python] Open a popup in Edge browser using subprocess and fixed text in the window bar name...

Discussão em 'Python' iniciado por Stack, Abril 6, 2025.

  1. Stack

    Stack Membro Participativo

    To open a popup I use subprocess:

    import subprocess
    EDGE_PATCH = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
    url = "https://www.google.com/"
    subprocess.Popen([EDGE_PATCH, f'--app={url}'])


    But I noticed that for the website I use, even though they are broadcasts of different events, the name is always Leitor LiveVideo instead of showing the name of the event and this really bothers me when I want to open it in full screen because it takes a while for me to figure out which one I need to maximize:

    [​IMG]

    I tried to create a local HTML and use it as a base and add the url inside an iframe, but the site is all white and it seems to be blocked from being placed inside an iframe:

    HTML:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Placeholder</title>
    <style>
    body { margin: 0; padding: 0; overflow: hidden; }
    iframe { width: 100%; height: 100vh; border: none; }
    </style>
    </head>
    <body>
    <iframe id="content" src=""></iframe>
    <script>
    const urlParams = new URLSearchParams(window.location.search);
    const home_name = urlParams.get('home');
    const away_name = urlParams.get('away');
    const url = urlParams.get('url');
    document.title = `${home_name} x ${away_name}`;
    document.getElementById('content').src = url;
    </script>
    </body>
    </html>


    Python:

    import subprocess
    import urllib.parse

    EDGE_PATCH = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
    wrapper_path = r"C:\Users\Computador\Desktop\tests\wrapper.html"

    home_name = "Team A"
    away_name = "Team B"
    original_url = "https://google.com/" # url example

    encoded_url = urllib.parse.quote(original_url, safe=':/')
    url = f"{wrapper_path}?home={home_name}&away={away_name}&url={encoded_url}"

    subprocess.Popen([EDGE_PATCH, f'--app={url}'])


    Now I can set the title but it's useless because the page doesn't open:

    [​IMG]

    Is there any way I can already set this value in a fixed way when creating the pop-up using suprocess with --app or any other way to achieve this result without causing access blocks as happens when trying to place it in an local html iframe and the like?

    I wanted to open it as I normally do, I just really wanted to change this text and nothing else to have a descriptive name.

    Continue reading...

Compartilhe esta Página