python ctypes get current window code example Example: python ctypes get current window import ctypes window = ctypes.windll.user32.GetForegroundWindow()