0

I am trying to get the currently active window's address in the address bar but there does not seem like there is any module that can do this.

I already looked at pywin32 and it looks like what I am looking for but there isn't any function that retrieves the text in the address bar.

Stein
  • 3
  • 3

1 Answers1

0

You could try:

  • set file explorer to be currently active window
  • send in alt+D keystroke to focus the address bar
  • send in ctrl+C keystroke to copy to the windows clipboard
  • follow up with this stackoverflow post to read in data from the clipboard

and if you're unsure how to simulate keystrokes, there's plenty of googling for that.

good luck!

cptwonton
  • 500
  • 3
  • 16
  • yes this would work but wouldn't it overwrite the content of the clipboard? and can the previous content be saved? – Stein Jan 23 '18 at 19:17
  • if you want to preserve the clipboard, you can also read from/write to/clear the clipboard using python. i'll let it up to you on how you want to handle that, there's a few ways you can go about it. my suggestion is just a way to accomplish what you're looking for since win32 doesn't have this functionality readily available – cptwonton Jan 23 '18 at 19:19