Ce qui suit pour moi.
from win32com.client import Dispatch
SHELL = Dispatch("Shell.Application")
def get_ie(shell):
for win in shell.Windows():
if win.Name == "Windows Internet Explorer":
return win
return None
def main():
ie = get_ie(SHELL)
if ie:
print ie.LocationURL
else:
print "no ie window"
if __name__ == '__main__':
main()
J'ai essayé d'utiliser Dispatch('InternetExplorer.Application')
pour se connecter à la fenêtre actuelle IE, mais il serait toujours créer une nouvelle fenêtre. Le code aurait été plus simple.
# This doesn't work
from win32com.client import Dispatch
# This line will always create a new window
ie = Dispatch("InternetExplorer.Application")
print ie.LocationURL
merci pour la réponse. mais je suis besoin d'une barre d'adresse. pas besoin de titre. –