Microsoft KB Archive/201833

{|
 * width="100%"|

PRB: Behavior of Screen Saver with keybd_event and mouse_event

 * }

Q201833

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), on platform(s):
 * the operating system: Microsoft Windows NT
 * the operating system: Microsoft Windows 95
 * the operating system: Microsoft Windows 98

-

SYMPTOMS
Screen savers react differently to keybd_event and mouse_event APIs on different operating systems. Usually, on getting the keyboard or mouse event, a screen saver should close or bring up a password dialog box (if it is password-protected) on a keyboard/mouse event. Even if it assumed that the screen saver closes on a keyboard/mouse event, the behavior is not the same across the different Windows operating systems. This article lists screen saver behavior on different operating systems.

MORE INFORMATION
When the screen saver is active and keybd_event or mouse_event is invoked programatically at the user level to synthesize a keystroke or to synthesize mouse action, respectively, the behavior described below occurs. (When these API's are called at the driver level, they behave appropriately; that is, they always reset the screen saver timer or terminate the screen saver if it is already running.)

Windows 95, 98:

If keybd_event is sent before the screen saver's timer times out, keybd_event prevents the screen saver from running by resetting its timer; however, mouse_event can not do this. Also, the currently running screen saver is terminated by keybd_event, but not by mouse_event.

Windows NT 3.51, 4.0:

If mouse_event is sent before the screen saver's timer times out, mouse_event prevents the screen saver from running by resetting its timer; however, keybd_event can not do this. If the screen saver is already running, then neither keybd_event nor mouse_event can terminate it because it is running in a different desktop.

The workaround for this is described in the following article in the Microsoft Knowledge Base:

"Q140723 HOWTO: Force a ScreenSaver to Close Once Started in Windows NT"

This behavior may change in Windows 2000.