On windows, use ctypes to check if we should enter safe mode.

Fixes #316. It looks like using pygame to detect keypresses on an
unmapped window is now broken, perhaps since the most recent
pygame upgrade.