tags:

views:

33

answers:

1

How can I get the window name?

I want to make a script where I have some keyboard event, and I want it to happens only if the window name has something in the name, like, Firefox.

how can I do it?

the simplest way

+2  A: 

If by "window name" you mean "window title", and assuming you have the window's handle in hwnd,

import win32gui
thetitle = win32gui.GetWindowText( hwnd )

You need to download win32gui and the other "windows extensions for Python" from here, of course, and install them on your machine.

If you mean something else, please clarify!

Alex Martelli