4
Some time ago I started using pyHook to manipulate events. However, the original version has errors, so I switched it to an alternative version that corrected the errors of the original version. However, I found that this alternate version always shows an empty string for the method that returns the name of the window that is focused.
from pyHook import HookManager
from python import PumpMessages
def evento_teclado(event):
print(event.WindowName())
return True
hm=HookManager()
hm.KeyDown=evento_teclado
hm.HookKeyboard()
PumpMessages()
This script always shows an empty string. Is there any other way to get the window name?
What OS? If it’s Windows, have you tried?
import win32gui
 win32gui.GetWindowText (w.GetForegroundWindow())
?– Leonardo Pessoa
It’s Windows. And it worked. It puts the answer I accept. @leonardopessoa
– Benedito