Show / Hide Table of Contents

Class inputBlocker

Blocks keyboard and/or mouse input events from reaching applications.

public sealed class inputBlocker : IDisposable
Remarks

Uses keyboard and/or mouse hooks. Does not use API BlockInput, it does not work on current Windows versions. Blocks hardware-generated events and software-generated events, except generated by functions of this library. Functions of this library that send keys or text use this class internally, to block user-pressed keys and resend them afterwards (see inputBlocker.ResendBlockedKeys). Does not block:

  • In windows of the same thread that started blocking. For example, if your script shows a message box, the user can click its buttons.
  • In windows of higher UAC integrity level (IL) processes, unless this process has uiAccess IL.
  • In special desktops/screens, such as when you press Ctrl+Alt+Delete or launch an admin program that requires UAC elevation. See also inputBlocker.ResumeAfterCtrlAltDelete.
  • Some Windows hotkeys, such as Ctrl+Alt+Delete and Win+L.
  • Keyboard hooks don't work in windows of this process if this process uses direct input or raw input API.

To stop blocking, can be used using, like in the example. Or try with finally code that calls inputBlocker.Dispose or inputBlocker.Stop. Also automatically stops when this thread ends. Users can stop with Ctrl+Alt+Delete.

Examples
using(new inputBlocker(BIEvents.All)) {
	print.it("blocked");
	5.s();
}
print.it("not blocked");

Namespace: Au
Assembly: Au.dll
Inheritance
object
inputBlocker

Constructors

Name Description
inputBlocker()

This constructor does nothing (does not call inputBlocker.Start).

inputBlocker(BIEvents)

This constructor calls inputBlocker.Start.

Properties

Name Description
DontBlockInjected

Don't block software-generated key/mouse events. If false (default), only events generated by functions of this library are not blocked.

Pause

Gets or sets whether the blocking is paused.

ResendBlockedKeys

Record blocked keys, and play back when stopped blocking.

ResumeAfterCtrlAltDelete

Continue blocking when returned from a special screen where blocking is disabled: Ctrl+Alt+Delete, UAC consent, etc.

Methods

Name Description
Dispose()

Calls inputBlocker.Stop.

Start(BIEvents)

Starts blocking.

Stop(bool)

Stops blocking. Plays back blocked keys if need. See inputBlocker.ResendBlockedKeys. Does nothing if currently is not blocking.