Код: Выделить всё
import pygetwindow as gw
import subprocess
import ctypes
import time
def open_and_rename(url: str, new_title: str):
windows_before = set(gw.getAllTitles())
subprocess.Popen([r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe", '--new-window', url])
time.sleep(1)
windows_after = set(gw.getAllTitles())
new_windows = windows_after - windows_before
if new_windows:
new_window_title = list(new_windows)[0]
window = gw.getWindowsWithTitle(new_window_title)[0]
hwnd = window._hWnd
ctypes.windll.user32.SetWindowTextW(hwnd, new_title)
else:
print("new window not found")
open_and_rename("https://www.google.com/", "Test")
с этим вариантом. Браузер (этот вариант, который вы обнаружите, нажав правую сторону мыши как в верхней части окна, так и в одном и том же действии на миниатюре окна, оставляя мышь на ней на панели задач)
Есть ли способ сделать это на Python + Windows 11 без использования Python Moving Simulators and Clicks and Clicks and Clips and Keyboard?>
Подробнее здесь: https://stackoverflow.com/questions/797 ... reshing-we