You need to specify DISCL_FOREGROUND when setting cooperative level in DirectInput to prevent this from happening.