I was trying to use uiautomation's python wrapper to get the active url of a chrome window. However, this script was only getting certain websites (such as youtube or google) and not others (stackoverflow, reddit, github etc.)
import win32gui as win
import time
import uiautomation as auto
while True:
window = win.GetForegroundWindow()
win_name = win.GetWindowText(window)
if "Google Chrome" in win_name:
chromeControl = auto.ControlFromHandle(window)
edit = chromeControl.EditControl()
print('https://' + edit.GetValuePattern().Value)
I have tried almost every post regarding this matter to no avail. Apparently chrome has changed their window class names etc. Any help would be appreciated.