-3

Is there a way to define what window is being used in python? Such as, if I have three separate Firefox windows open, how would i get a python program to know which one I am looking at/scrolling through/clicking on/typing in? I am having a really hard time trying to find a good way of describing this so if you don't understand please tell me so i can elaborate. I cant really decide what to type into Google to solve this so anything would help. i am using Windows 7.

  • What operating system are you using? – jmunsch Sep 30 '14 at 12:41
  • Try using `pywin32` and `win32gui` then from there read and search the documentation: http://docs.activestate.com/activepython/3.2/pywin32/ – jmunsch Sep 30 '14 at 12:45
  • 1
    I may have found what i need win32ui.GetForegroundWindow and/or win32ui.GetActiveWindow. I don't know yet but you have given me what I need to show myself thx! – RagingSu5hi Sep 30 '14 at 13:01

1 Answers1

0

Here is a simple example:

import win32gui
win = win32gui
while True:
    print(win.GetWindowText(win.GetActiveWindow()))

If the module is documented well enough try help(win32gui) after it is imported.

jmunsch
  • 19,902
  • 9
  • 82
  • 102