-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
  • 22,771
  • 11
  • 93
  • 114
  • Thanks so much for helping with this! Your time helping me will be put to productive use! – RagingSu5hi Sep 30 '14 at 13:18
  • @RagingSu5hi There is an example of how the handlers and callbacks work here: http://stackoverflow.com/questions/2090464/python-window-activation – jmunsch Sep 30 '14 at 13:20
  • @RagingSu5hi If and when you get around to it, try updating your question with some code examples on your specific problem. – jmunsch Sep 30 '14 at 13:24