GetWindowLongW returns signed int; bitwise ops with WS_POPUP (0x80000000) overflow ctypes c_long. Fixed with & 0xFFFFFFFF mask + ctypes.c_long() cast. Also tightened window class filter: pid_match now requires known mstsc class. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>