I write a python program that should run when a certain window is open and in focus.
For this, I need 2 things:
- I need to know how to find which window has focus currently.
- I need to know if there is a focus change event.
Tried using win32api and win32gui with no success.
How can I do it?
Example to clerify - say I want to write "geronimo" every time I focus notepad.
- I run the program (notepad closed, nothing happens)
- I open notepad (it should write geronimo)
- I change focus to chrome (nothing happens)
- I change focus back to notepad (writes geronimo again)