Skip to content

Instantly share code, notes, and snippets.

@illixion
Created April 11, 2023 12:44
Show Gist options
  • Save illixion/ef97f532a605f6ec4684eaf81bcc6b9a to your computer and use it in GitHub Desktop.
Save illixion/ef97f532a605f6ec4684eaf81bcc6b9a to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# Finds any application that's stealing window focus and prints its name to the output
# Works on Windows 10/11
# Install requirements with: pip install win32gui
from win32gui import GetWindowText, GetForegroundWindow
import time
active_prev = ""
while True:
time.sleep(0.1)
activeAppName = GetWindowText(GetForegroundWindow())
if activeAppName != active_prev:
print(activeAppName)
active_prev = activeAppName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment