Files
py-media-grader/croppa/utils.py

14 lines
476 B
Python

import ctypes
def get_active_window_title():
"""Get the title of the currently active window"""
try:
hwnd = ctypes.windll.user32.GetForegroundWindow()
length = ctypes.windll.user32.GetWindowTextLengthW(hwnd)
buffer = ctypes.create_unicode_buffer(length + 1)
ctypes.windll.user32.GetWindowTextW(hwnd, buffer, length + 1)
return buffer.value
except: # noqa: E722 - preserve original broad exception style
return ""