hi;
i need grab to internet explorer address bar. how to get address bar url for python ? (i need second part other browsers grabbing address bar but internet explorer is urgently).
Thanks.
hi;
i need grab to internet explorer address bar. how to get address bar url for python ? (i need second part other browsers grabbing address bar but internet explorer is urgently).
Thanks.
Would something like this not work?
import win32gui
def get_current_window_title():
cur_hwnd = win32gui.GetForegroundWindow()
win_title = win32gui.GetWindowText(cur_hwnd)
return win_title
The following works for me.
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()
I tried to use Dispatch('InternetExplorer.Application')
to connect to current IE window, but it would always create a new window. The code would have been simpler.
# This doesn't work
from win32com.client import Dispatch
# This line will always create a new window
ie = Dispatch("InternetExplorer.Application")
print ie.LocationURL