Firefoxのアドレスバーをつかむ必要があります。PythonのアドレスバーのURLを取得する方法は?(私は2番目の部分の他のブラウザのクロームとサファリがアドレスバーをつかむ必要がありますが、Firefoxは緊急です)。
ありがとう。
すべてのトップ ウィンドウを通過し、タイトルに Firefox が含まれているかどうかを確認するか、spy++ を使用して Firefox のウィンドウ クラスを確認してから、すべての子ウィンドウを通過して URL を見つけます。
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)
また、このモジュールを使用して、そのようなタスクのほとんどを実行でき ます http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html