Question

i need grab to firefox address bar. how to get address bar url for python ? (i need second part other browsers chrome and safari grabbing address bar but firefox is urgently).

Thanks.

Was it helpful?

Solution

You will need to go thru all top windows, and see if title contains firefox or check window class of firefox using spy++, then go thru all child windows to find URL, as a starting point do something like this

import win32gui

def enumerationCallaback(hwnd, results):
    text = win32gui.GetWindowText(hwnd)
    if text.find("Mozilla Firefox") >= 0:
        results.append((hwnd, text))

mywindows = []    
win32gui.EnumWindows(enumerationCallaback, mywindows)
for win, text in mywindows:
    print text

def recurseChildWindow(hwnd, results):
    win32gui.EnumChildWindows(hwnd, recurseChildWindow, results)
    print hwnd
    # try to get window class, text etc using SendMessage and see if it is what we want

mychildren = []
recurseChildWindow(mywindows[0][0], mychildren)

Also you can use this module to do most of such tasks http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top